如何在Windows上使用Python 3.4的pip?
我刚在Windows 7上安装了全新的Python 3.4.1版本。这里说pip是默认包含的,但我找不到任何pip.exe或者相关的pip命令。我需要单独安装它吗,还是它在某个地方存在?
9 个回答
在Python 3中使用pip
安装软件包
第一步:安装Python 3。默认情况下,应用程序文件pip3.exe
已经在路径中,位置大概是:
C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts
第二步:接下来,去到
>Control Panel (Local Machine) > System > Advanced system settings >
>Click on `Environment Variables` >
Set a New User Variable, for this click `New` >
Write new 'Variable name' as "PYTHON_SCRIPTS" >
Copy that path of `pip3.exe` and paste within variable value > `OK` >
>Below again find out and click on `Path` under 'system variables' >
Edit this path >
Within 'Variable value' append and paste the same path of `pip3.exe` after putting a ';' >
Click `OK`/`Apply` and come out.
第三步:现在,按下Windows+R
键打开cmd
命令行窗口。
> Write 'pip3' and press 'Enter'. If pip3 is recognized you can go ahead.
第四步:在这个cmd
窗口中
> Write path of the `pip3.exe` followed by `/pip install 'package name'`
比如你可以输入:
C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts/pip install matplotlib
然后按Enter
键。软件包matplotlib
就会开始下载。
另外,如果你想升级某个软件包
再次打开cmd
命令行窗口,然后
输入
pip3.exe
的路径,后面加上/pip install --upgrade '软件包名称'
,然后按Enter
。
比如你可以输入:
C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts/pip install --upgrade matplotlib
软件包的升级就会开始了:)
来自同一页面
注意:为了避免在同时安装Python 2和Python 3时出现冲突,默认情况下,当直接调用ensurepip时,只会启动带版本号的pip3和pip3.4命令。如果你想要使用没有版本号的pip命令,需要加上--default-pip选项。pyvenv和Windows安装程序会确保在这些环境中可以使用没有版本号的pip命令,而在有多个Python安装的系统中,可以通过-m选项来调用pip,这样可以避免混淆。
所以在命令提示符中试试 pip3
或 pip3.4
。
另外,如果你没有选择自动配置PATH
,请确保环境变量已经设置好,以便使用pip命令。
在Windows和Mac OS X系统上,CPython的安装程序现在默认会和CPython一起安装pip(用户可以选择不安装pip)。Windows用户需要在安装过程中选择自动修改PATH,这样才能在命令行中默认使用pip。如果不选择这个选项,仍然可以通过Windows的Python启动器来使用pip,方法是输入py -m pip。
你试过吗?
假设你没有其他的Python安装,默认安装后你应该可以用 python -m pip
这个命令。你的系统路径里应该有类似下面的内容:
C:\Python34\Scripts
如果你把Python安装在其他地方,这个路径肯定会有所不同。
我在用Windows 7,Python版本是3.4.1;按照Guss建议的命令运行,效果很好。
C:\Users>py -m pip install requests
输出结果
Downloading/unpacking requests
Installing collected packages: requests
Successfully installed requests
Cleaning up...