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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 16:57:36  来源:igfitidea点击:

How to use pip in Windows?

pythoninstallpip

提问by ChangeMyName

I am trying to install some modules using pip. My system is Windows 7 64-bit, and I'm using Python Shelland Python 2.7.

我正在尝试使用pip. 我的系统是Windows 7 64-bit,我正在使用Python ShellPython 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 piphighlighted 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?

如何在 Windows 上安装 pip?

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