如何在 Windows 上将 pip 与 python 3.4 一起使用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24285508/
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 04:22:24  来源:igfitidea点击:

How to use pip with python 3.4 on windows?

pythonpython-3.xpip

提问by Kin

Just installed a fresh copy of python 3.4.1 on windows 7. Heresays that pip is included by default. but i could not find any pip.exe or some pip commands. Do I need to install it separately or it exists somewhere?

刚刚在 Windows 7 上安装了 python 3.4.1 的新副本。这里说默认情况下包含 pip。但我找不到任何 pip.exe 或一些 pip 命令。我需要单独安装它还是存在于某个地方?

回答by Alessandro Suglia

"On Windows and Mac OS X, the CPython installers now default to installing pip along with CPython itself (users may opt out of installing it during the installation process). Window users will need to opt in to the automatic PATH modifications to have pip available from the command line by default, otherwise it can still be accessed through the Python launcher for Windows as py -m pip."

“在 Windows 和 Mac OS X 上,CPython 安装程序现在默认安装 pip 和 CPython 本身(用户可以在安装过程中选择不安装它)。Window 用户需要选择加入自动 PATH 修改以使 pip 可用默认情况下从命令行,否则仍然可以通过适用于 Windows 的 Python 启动器作为 py -m pip 访问它。”

Have you tried it?

你试过吗?

回答by parth

From the same page

同一页面

Note:To avoid conflicts between parallel Python 2 and Python 3 installations, only the versioned pip3 and pip3.4 commands are bootstrapped by default when ensurepip is invoked directly - the --default-pip option is needed to also request the unversioned pip command. pyvenv and the Windows installer ensure that the unqualified pip command is made available in those environments, and pip can always be invoked via the -m switch rather than directly to avoid ambiguity on systems with multiple Python installations.

注意:为了避免并行 Python 2 和 Python 3 安装之间的冲突,当直接调用 ensurepip 时,默认情况下仅引导版本控制的 pip3 和 pip3.4 命令 - 还需要 --default-pip 选项来请求未版本控制的 pip 命令。pyvenv 和 Windows 安装程序确保在这些环境中可以使用不合格的 pip 命令,并且始终可以通过 -m 开关调用 pip 而不是直接调用,以避免在具有多个 Python 安装的系统上产生歧义。

So try pip3or pip3.4in Command Prompt.

所以尝试pip3pip3.4在命令提示符下。

Also, ensure that environment variable are set for pip command, if you missed to opt-in for automatic PATHconfiguration.

此外,如果您错过了选择自动PATH配置的选项,请确保为 pip 命令设置了环境变量。

回答by aether34

Assuming you don't have any other Python installations, you should be able to do python -m pipafter a default installation. Something like the following should be in your system path:

假设您没有任何其他 Python 安装,您应该可以python -m pip在默认安装后进行。您的系统路径中应包含以下内容:

C:\Python34\Scripts

C:\Python34\Scripts

This would obviously be different, if you installed Python in a different location.

如果您将 Python 安装在不同的位置,这显然会有所不同。

回答by slacker

i have Windows7 Python 3.4.1; following command suggested by Guss worked well

我有 Windows7 Python 3.4.1;Guss 建议的以下命令运行良好

C:\Users>py -m pip install requests

Output

输出

Downloading/unpacking requests
Installing collected packages: requests
Successfully installed requests
Cleaning up...

回答by S M

I had the same issue. The problem is that pip install tries to use C:\Users(username)\AppData\Local\Temp to unpack. You have to explicitly set those directories to R/W.I still couldn't do it because it was a work laptop and there were some permissions issues with trying to set these directories to R/W. The alternative is to go to your Env Variables, and set both Tmp and Temp to point to a writeable directory such as C:. The installation went fine. I was able to install pip.

我遇到过同样的问题。问题是 pip install 尝试使用 C:\Users(username)\AppData\Local\Temp 来解压。您必须将这些目录明确设置为 R/WI 仍然无法做到,因为它是一台工作笔记本电脑,并且在尝试将这些目录设置为 R/W 时存在一些权限问题。另一种方法是转到您的环境变量,并将 Tmp 和 Temp 设置为指向可写目录,例如 C:。安装很顺利。我能够安装pip。

The way I stumbled onto this is by not defaulting pip install in my installation. Even though the pip install was failing, the installer was not giving any errors. Removing pip and then trying to manually add it later is what pointed to what was going on.

我偶然发现的方法是在我的安装中没有默认 pip install 。即使 pip 安装失败,安装程序也没有给出任何错误。删除 pip 然后尝试稍后手动添加它是指向正在发生的事情的原因。

回答by SUNIL8055

"py -m pip install requests" works fine with Windows and its up gradation. Just change the path after installing Python 3.4 in the command prompt and type in "py -m pip install requests"command prompt. pip install

“py -m pip install requests”适用于 Windows 及其升级。只需在命令提示符中安装 Python 3.4 后更改路径并键入“py -m pip install requests”命令提示符即可。点安装

回答by xiaoxu

I had the same problem when I install python3.5.3. And finally I find the pip.exe in this folder: ~/python/scripts/pip.exe. Hope that help.

我在安装 python3.5.3 时遇到了同样的问题。最后我在这个文件夹中找到了 pip.exe:~/python/scripts/pip.exe。希望有所帮助。

回答by shubh

Usage of pipfor installation of packages in Python 3

用法pip在Python安装包3

Step 1:Install Python 3. Yes, by default an application file pip3.exeis already located there in the path (E.g.):

第 1 步:安装 Python 3。是的,默认情况下,应用程序文件pip3.exe已位于路径 ( E.g.) 中:

C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts

C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts

Step 2:Go to

第 2 步:转到

>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.

Step 3:Now, open cmdbash/shell by Pressing key Windows+R.

第 3 步:现在,cmd按 键打开bash/shell Windows+R

> Write 'pip3' and press 'Enter'. If pip3 is recognized you can go ahead.

Step 4:In this same cmd

第 4 步:在同样的cmd

> Write path of the `pip3.exe` followed by `/pip install 'package name'`

As Example just write:

作为示例只需写:

C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts/pip install matplotlib

C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts/pip install matplotlib

Press Enternow. The Package matplotlibwill start getting downloaded.

Enter现在按。软件包matplotlib将开始下载。

Further, for upgrading any package

此外,对于升级任何包

Open cmdbash/shell again, then

cmd再次打开bash/shell,然后

type that path of pip3.exefollowed by /pip install --upgrade 'package name'Press Enter.

键入该路径,pip3.exe然后/pip install --upgrade 'package name'Enter

As Example just write:

作为示例只需写:

C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts/pip install --upgrade matplotlib

C:/Users/name/AppData/Local/Programs/Python/Python36-32/Scripts/pip install --upgrade matplotlib

Upgrading of the package will start :)

包的升级将开始 :)