Python Forum
pip install syntax errror again and again
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pip install syntax errror again and again
#1
Dear all,

I am coming across a frustrating issue with python when it comes to packages installation. To put it bluntly, the famous "pip install package" command line that it is recommended by the creators DOES NOT WORK: SyntaxError: invalid syntax.

However, if I type "pip.main(['install', 'package']) it works...

I import pip before installing packages, my PATH is OK, as well as the Environment VAriables. I am using python 3.6 x64 on Win 10 and Win 7 (I am working on many machines some new, out of the box, and some old).

My question is how come this happens even with new, clean installations on each machine?

It is very frustrating... makes a Matlab license work the cost...

Best regards,
Jean
Reply
#2
Quote:DOES NOT WORK: SyntaxError: invalid syntax.
a syntax error means you are putting the command into the python interactive prompt. You dont do that. You put the command into the operating systems prompt.

See here for more info
Executing Python and pip instructions
Recommended Tutorials:
Reply
#3
You are doing pip.main('install', 'package']) when you are using pip inside a python interpreter or in Python script. If you just want to install a package see the previous post.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
Thank you very much metulburr!

The documentation is not very clear I should run the pip command in command prompt, thank you for clearing this out for me !
Reply
#5
I am a beginner and a bit confused... I got the syntax error as well when running in the Python 3.7 black command prompt thingie. However, when I use pip.main(['install', 'package'], it replies ... and i dont know what to do after that...

Nevermind.... I got it to work
Reply
#6
Just in case anyone has the problem I just had, I thought I'd share.

I had a command prompt open on my computer and installed Python 3.72 with pip.

I then went to the command prompt and attempted to start installing packages with pip, but continuously got "'pip' is not recognized as an internal or external command".

I changed directory in the command prompt to the python/scripts directory and typed "pip" and got the pip help screen as expected. So I figured that the problem must be that the python/scripts wasn't in my path as an environment variable. But when I checked, it was already there.

Turns out that a command prompt isn't updated with new PATH info. You have to close existing command prompts and start new ones in order to have the new environment variables. Ran a new command prompt and all was well... except for me feeling a bit foolish! ;-)

Joe
Reply


Forum Jump:

User Panel Messages

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