Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
181 views
in Technique[技术] by (71.8m points)

python - How to install packages with pip in Windows PowerShell

I am using Python 2.7.9 on a Windows 8 computer.

I tried to install lxml by typing pip install lxmlin Windows PowerShell after typing python, but I get the following error: SyntaxError: invalid syntax

I tried installing pip by using the following tutorial http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/ only to later realize that I already had pip.exe, pip2.7.exe and pip2.exe installed when I first installed Python. They are located in the C:Python27Scripts directory.

Yet, if I try something like pip help I will get an invalid syntax error.

Do I have to reinstall pip or how do I get it to work in order to install the lxml library.

Thank you for any help you can provide.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same problem. You need to set the PATH environment variable, so that the system recognizes the command "pip".

If typing easy_install or pip [in PowerShell] doesn’t work, it means the Scripts folder is not in your path. Run the next command in that case (Note that this command must be run only once or your PATH will get longer and longer). Make sure to replace c:Python33Scripts with the correct location of your Python installation:

setx PATH "%PATH%;C:Python33Scripts"

Close and reopen PowerShell after running this command.

Source: http://arunrocks.com/guide-to-install-python-or-pip-on-windows/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...