如何在 Windows 的 python 上运行 pip? [英] How do I run pip on python for windows?
问题描述
我刚刚安装了 python 3.5,运行了 Python 3.5 (32-bit)
并输入了
pip
并收到消息:
回溯(最近一次调用最后一次):文件<pyshell#2>",第 1 行,在 <module> 中点子NameError: 名称 'pip' 未定义
我在我的路径中没有看到任何脚本目录,但我在 C:\Users\UserName\AppData\Local\Programs\Python\Python35-32 中找到了
.pip.py
\Scripts
我在安装过程中选择了将python添加到环境变量"选项,但它似乎没有做任何事情.
我用谷歌搜索了这个并得到了本指南,这表示早期版本需要添加一些路径名.我没有 C:\Python...
目录,所以我尝试从上面添加 Scripts
文件夹,结果相同.
我如何安装 python 以使其实际工作(即,我可以运行 pip、安装模块等)?
也许你想尝试像这样在 Python shell 中运行 pip
:
这将使用 pip
安装 requests
包.
因为pip
是标准库中的一个模块,但不是内置函数(或模块),所以需要导入.
其他方式,你应该在系统shell(cmd.如果pip
在路径中)运行pip
.
I've just installed python 3.5, ran Python 3.5 (32-bit)
and typed
pip
and received the message:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
pip
NameError: name 'pip' is not defined
I don't see any scripts directories in my path, but I found pip.py
in C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\Scripts
.
I selected the option to "Add python to environment variables" during installation, but it doesn't seem to have done anything.
I googled this and got this guide, which says that earlier versions need to add some path names. I don't have a C:\Python...
directory so I tried adding the Scripts
folder from above, same result.
How do I install python so that it actually works (ie. I can run pip, install modules, etc.)?
Maybe you'd like try run pip
in Python shell like this:
>>> import pip
>>> pip.main(['install', 'requests'])
This will install requests
package using pip
.
Because pip
is a module in standard library, but it isn't a built-in function(or module), so you need import it.
Other way, you should run pip
in system shell(cmd. If pip
is in path).
这篇关于如何在 Windows 的 python 上运行 pip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!