如何在 Windows PowerShell 中使用 pip 安装包 [英] How to install packages with pip in Windows PowerShell
问题描述
我在 Windows 8 计算机上使用 Python 2.7.9.
I am using Python 2.7.9 on a Windows 8 computer.
我尝试通过在 Windows PowerShell 中键入 python
后键入 pip install lxml
来安装 lxml,但出现以下错误:SyntaxError: invalid syntax代码>
I tried to install lxml by typing pip install lxml
in Windows PowerShell after typing python
, but I get the following error: SyntaxError: invalid syntax
我尝试使用以下教程安装 pip http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/后来才意识到我第一次安装Python时已经安装了pip.exe、pip2.7.exe和pip2.exe.它们位于 C:Python27Scripts 目录中.
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.
然而,如果我尝试像 pip help
这样的东西,我会得到一个无效的语法错误.
Yet, if I try something like pip help
I will get an invalid syntax error.
我是否必须重新安装 pip 或者如何让它工作才能安装 lxml 库.
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.
推荐答案
我遇到了同样的问题.需要设置PATH环境变量,让系统识别pip"命令.
I had the same problem. You need to set the PATH environment variable, so that the system recognizes the command "pip".
如果在 PowerShell 中输入 easy_install 或 pip 不起作用,则意味着 Scripts 文件夹不在您的路径中.在这种情况下运行下一个命令(请注意,此命令只能运行一次,否则您的 PATH 会越来越长).确保将 c:Python33Scripts 替换为 Python 安装的正确位置:
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"
运行此命令后关闭并重新打开 PowerShell.
Close and reopen PowerShell after running this command.
来源:http://arunrocks.com/guide-to-install-python-or-pip-on-windows/
这篇关于如何在 Windows PowerShell 中使用 pip 安装包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!