Python 如何在 Windows 中使用 pip?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35793489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use pip in Windows?
提问by ChangeMyName
I am trying to install some modules using pip
. My system is Windows 7 64-bit
, and I'm using Python Shell
and Python 2.7
.
我正在尝试使用pip
. 我的系统是Windows 7 64-bit
,我正在使用Python Shell
和Python 2.7
。
I've typed in following code to start the installation:
我输入了以下代码来开始安装:
python -m pip install traitlets
According to this page, the above code should work. However I've got pip
highlighted in red and an error message:
根据这个页面,上面的代码应该可以工作。但是,我pip
以红色突出显示并显示错误消息:
SyntaxError: invalid syntax
Can someone please point out what is wrong with my code?
有人可以指出我的代码有什么问题吗?
回答by Stop harming Monica
You have to execute that command in a windows command prompt, not in a python shell.
您必须在 Windows 命令提示符中执行该命令,而不是在 python shell 中。
回答by JRazor
How do I install pip on Windows?
This installed Pip at C:\Python27\Scripts\pip.exe. Find pip.exe on your computer, then add its folder (for example, C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:
这将 Pip 安装在 C:\Python27\Scripts\pip.exe。在您的计算机上找到 pip.exe,然后将其文件夹(例如,C:\Python27\Scripts)添加到您的路径(启动/编辑环境变量)。现在您应该能够从命令行运行 pip。尝试安装一个包:
pip install httpie
pip 安装 httpie