Python Forum
Pip Syntax Errors in CMD: Windows 10 and Python 3.8.1
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pip Syntax Errors in CMD: Windows 10 and Python 3.8.1
#1
Ok-

There a many threads out there on pip giving syntax errors, but none of their solutions are working for me.

I'm using Windows 10 home (build 18363.592) | Python 3.8.1 | Intel i7 9th Gen + Geforce rtx 2060

I installed Python with an exe from python.org, including it in the path (as user), checked the program files (pip is there), checked again with help('modules'), and made sure it's in the user path with system environment variables.

Yet I can't get pip to work in the CMD:

>>> C:\Users\james>python -m pip install numpy
File "<stdin>", line 1
C:\Users\james>python -m pip install numpy
^
SyntaxError: unexpected character after line continuation character

or
>>> C:\Users\james>python -m pip -V
File "<stdin>", line 1
C:\Users\james>python -m pip -V
^
SyntaxError: unexpected character after line continuation character

As a work around to get numpy (my goal), I went into the shell and ran pip.main(['install','numpy']), and it ironically replied:

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.



After downloading numpy-1.18.1-cp38-cp38-win_amd64.whl, it ended with this:

[31mERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
numpy from https://files.pythonhosted.org/packages/...e9b8918c6a:
Expected sha256 39d2c685af15d3ce682c99ce5925cc66efc824652e10990d2462dfe9b8918c6a
Got 2b9c02b3cd35069da02759bf5b1fed44839fc497a8910dfc01801acb680e9ad0



Updating hashes and examining packages contents carefully are beyond my current skill level. But a quick module check and- no suprise- no numpy available.

Now, here's where it gets weird. After this downloading process, I went back to the CMD, put in a pip version request and it actually worked:

C:\Users\james>python -m pip --version
pip 20.0.2 from C:\Users\james\AppData\Local\Programs\Python\Python38\lib\site-packages\pip (python 3.8)

Buuuuuut, it then reverted back to the syntax error message listed above. Once again, no love for pip or numpy in the CMD.

I've ran python scripts/python wrappers in this Windows environment just fine, but I need numpy to finish a quadcopter/computer vision set up with some vive stations. Two days on this and I'm no further. Any thoughts or advice are very much welcome.
Reply
#2
(Feb-06-2020, 04:25 AM)jamesphopper Wrote: >>> C:\Users\james>python -m pip install numpy
This is not cmd,but Python's interactive shell >>>.
cmd tutorial .
(Feb-06-2020, 04:25 AM)jamesphopper Wrote: I went back to the CMD, put in a pip version request and it actually worked:

C:\Users\james>python -m pip --version
pip 20.0.2 from C:\Users\james\AppData\Local\Programs\Python\Python38\lib\site-packages\pip (python 3.8)
Here you are in right place and pip is working,it's here you shall do pip install numpy.
Look like this,also look at tutorial here just the same for 3.8.
# pip is downloading and installing automatic 
C:\Users>pip install numpy
Collecting numpy
  Downloading numpy-1.18.1-cp37-cp37m-win32.whl (10.8 MB)
     |████████████████████████████████| 10.8 MB 3.2 MB/s
Installing collected packages: numpy
Successfully installed numpy-1.18.1

# Test that it work
C:\Users>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
>>> numpy.__version__
'1.18.1'
>>> exit()

C:\Users>
Reply
#3
ah, yes. a very important distinction for a beginner to learn...

Thanks for taking the time to teach me, snippsat!

And thanks for linking the tutorials as well; very helpful!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  When does Python detect Errors? stamp1t 1 401 Oct-21-2023, 05:53 PM
Last Post: deanhystad
  Syntax errors: Struggling to setup enviroment and load packages AH56 5 2,724 Jun-30-2021, 01:01 PM
Last Post: AH56
  Rmarkdown opened by python code - errors Rav013 0 2,049 Apr-27-2021, 03:13 PM
Last Post: Rav013
  Python Request Errors PythonNoob1998 7 3,772 Jan-07-2021, 05:18 PM
Last Post: buran
  Python 3.7, Windows 7, Syntax Error hughdent 1 2,246 Mar-23-2020, 10:09 AM
Last Post: buran
  Python stops without errors shahgourav 4 2,706 Feb-04-2020, 11:44 PM
Last Post: micseydel
  Can the comments produce errors in python? newbieAuggie2019 9 4,169 Nov-26-2019, 12:19 AM
Last Post: micseydel
  Running into errors when installing pip and pip3 on python 2.7 and python 3.6 tej7gandhi 1 2,796 May-05-2019, 10:37 PM
Last Post: snippsat
  Does Python sqlite3 detect connection errors zatlas1 6 3,881 Jan-18-2019, 06:02 AM
Last Post: zatlas1
  pip errors on windows 10 arnjmllr 1 2,459 Oct-20-2018, 10:56 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020