如何在 Windows 上安装 pip?
pip
是 easy_install
。但是我应该在 Windows 上使用 easy_install
安装 pip
吗?有更好的办法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
pip
是 easy_install
。但是我应该在 Windows 上使用 easy_install
安装 pip
吗?有更好的办法吗?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(30)
Python 3.4+ 和 2.7.9+
好消息! Python 3.4(2014 年 3 月发布)和 Python 2.7.9(已发布2014 年 12 月)与 Pip 一起发货。这是所有 Python 版本中最好的功能。它使每个人都可以访问社区丰富的图书馆。新手不再因为设置困难而无法使用社区库。在与包管理器一起发布时,Python 加入了 Ruby、Node.js,Haskell,Perl,Go — 几乎所有其他当代语言,拥有大多数开源社区。谢谢你,Python。
如果您发现 pip 不可用,只需运行
ensurepip
。在 Windows 上:
<前><代码>py -3 -m Ensurepip
否则:
当然,这并不意味着Python打包问题就解决了。这种经历仍然令人沮丧。我在 Stack Overflow 问题中讨论了这个 Python 有包/模块管理系统吗?。
Python 3 ≤ 3.3 和 2 ≤ 2.7.8
违背其“包含电池”座右铭, Python 出厂时没有包管理器。更糟糕的是,直到最近,Pip 的安装都极其困难。
官方说明
按照 https://pip.pypa .io/en/stable/installing/#do-i-need-to-install-pip:
下载
get-pip.py
,小心将其保存为.py
文件而不是.txt
。然后,从命令提示符运行它:您可能需要管理员命令提示符才能执行此操作。按照以管理员身份启动命令提示符< /a>(微软 TechNet)。
这将安装 pip 包,其中(在 Windows 中)包含 ...\Scripts\pip.exe,该路径必须位于 PATH 环境变量中才能从命令行使用 pip(请参阅“替代说明”的第二部分,将其添加到你的路径,
替代说明
官方文档告诉用户从源代码安装 Pip 及其每个依赖项,这对于经验丰富的人来说是乏味的,而对于新手来说则非常困难,
Christoph Gohlke 准备了 Windows 安装程序(
.msi) 对于流行的 Python 软件包,他为所有 Python 版本(32 位和 64 位)构建安装程序
对于我,这将 Pip 安装在
C:\Python27\Scripts\pip.exe
中,在您的计算机上找到pip.exe
,然后添加其文件夹(例如) C:\Python27\Scripts
) 到您的路径(开始/编辑环境变量)。现在您应该能够从命令行运行pip
。尝试安装一个包:你就可以了(希望如此)!下面给出了常见问题的解决方案:
代理问题
如果您在办公室工作,您可能会使用 HTTP 代理。如果是这样,请设置环境变量
http_proxy
和https_proxy< /代码>
。大多数 Python 应用程序(和其他自由软件)都尊重这些。语法示例:
如果您真的很不幸,您的代理可能是 Microsoft NTLM 代理。自由软件无法应对。唯一的解决方案是安装一个免费软件友好的代理,转发到讨厌的代理。 http://cntlm.sourceforge.net/
找不到 vcvarsall.bat
Python 模块可以部分用 C 编写或 C++。 Pip 尝试从源代码进行编译。如果您没有安装和配置 C/C++ 编译器,您将看到此神秘的错误消息。
您可以通过安装 C++ 编译器 例如 MinGW 或 Visual C++。微软实际上发布了一个专门用于 Python 的工具。或者尝试适用于 Python 2.7 的 Microsoft Visual C++ 编译器。
通常,在 Christoph 的网站 查找您的软件包会更容易。
Python 3.4+ and 2.7.9+
Good news! Python 3.4 (released March 2014) and Python 2.7.9 (released December 2014) ship with Pip. This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded from using community libraries by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Node.js, Haskell, Perl, Go—almost every other contemporary language with a majority open-source community. Thank you, Python.
If you do find that pip is not available, simply run
ensurepip
.On Windows:
Otherwise:
Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this in the Stack Overflow question Does Python have a package/module management system?.
Python 3 ≤ 3.3 and 2 ≤ 2.7.8
Flying in the face of its 'batteries included' motto, Python ships without a package manager. To make matters worse, Pip was—until recently—ironically difficult to install.
Official instructions
Per https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip:
Download
get-pip.py
, being careful to save it as a.py
file rather than.txt
. Then, run it from the command prompt:You possibly need an administrator command prompt to do this. Follow Start a Command Prompt as an Administrator (Microsoft TechNet).
This installs the pip package, which (in Windows) contains ...\Scripts\pip.exe that path must be in PATH environment variable to use pip from the command line (see the second part of 'Alternative Instructions' for adding it to your PATH,
Alternative instructions
The official documentation tells users to install Pip and each of its dependencies from source. That's tedious for the experienced and prohibitively difficult for newbies.
For our sake, Christoph Gohlke prepares Windows installers (
.msi
) for popular Python packages. He builds installers for all Python versions, both 32 and 64 bit. You need to:For me, this installed Pip at
C:\Python27\Scripts\pip.exe
. Findpip.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 runpip
from the command line. Try installing a package:There you go (hopefully)! Solutions for common problems are given below:
Proxy problems
If you work in an office, you might be behind an HTTP proxy. If so, set the environment variables
http_proxy
andhttps_proxy
. Most Python applications (and other free software) respect these. Example syntax:If you're really unlucky, your proxy might be a Microsoft NTLM proxy. Free software can't cope. The only solution is to install a free software friendly proxy that forwards to the nasty proxy. http://cntlm.sourceforge.net/
Unable to find vcvarsall.bat
Python modules can be partly written in C or C++. Pip tries to compile from source. If you don't have a C/C++ compiler installed and configured, you'll see this cryptic error message.
You can fix that by installing a C++ compiler such as MinGW or Visual C++. Microsoft actually ships one specifically for use with Python. Or try Microsoft Visual C++ Compiler for Python 2.7.
Often though it's easier to check Christoph's site for your package.
-- 过时 -- 使用分发,而不是此处描述的 setuptools。 ---- 过时的 #2 -- 使用 setuptools,因为分发已被弃用。
正如您提到的,pip 不包含独立的安装程序,但您可以使用其前身 easy_install 来安装它。
所以:
C:\Python2x\
文件夹中(不要将整个文件夹复制到其中,仅复制内容),因为 python 命令不起作用在C:\Python2x
文件夹之外,然后运行:python setup.py install
将 python
C:\Python2x\Scripts
添加到您所在的 完毕。现在您可以使用
pip install package
轻松安装软件包,就像在 Linux 中一样:)-- Outdated -- use distribute, not setuptools as described here. ---- Outdated #2 -- use setuptools as distribute is deprecated.
As you mentioned pip doesn't include an independent installer, but you can install it with its predecessor easy_install.
So:
C:\Python2x\
folder (don't copy the whole folder into it, just the content), because python command doesn't work outsideC:\Python2x
folder and then run:python setup.py install
C:\Python2x\Scripts
to the pathYou are done.
Now you can use
pip install package
to easily install packages as in Linux :)2014 更新:
1) 如果您安装了 Python 3.4 或更高版本,pip 包含在 Python 中并且应该已经可以在您的系统上运行。
2) 如果您运行的是 Python 3.4 以下的版本,或者由于某种原因 pip 没有随 Python 3.4 一起安装,那么您可能会使用 pip 的官方安装脚本
get-pip.py
。 pip 安装程序现在为您获取 setuptools,并且无论架构如何(32 位或 64 位)都可以工作。安装此处详细说明并涉及:
我将把下面两组旧指令留给后代。
旧答案:
对于 64 位版本的 Windows 版本 - 由于 ez_setup,64 位 Windows + Python 过去需要单独的安装方法,但我已经测试了新的在运行 32 位 Python 和 64 位 Python 的 64 位 Windows 上使用分发方法,现在您可以对所有版本的 Windows/Python 2.7X 使用相同的方法:
旧方法 2 使用 分发:
C:\Python27\Scripts
中(如果Scripts
目录不存在,请随意创建它。cd
) 到您已下载的目录distribute_setup.py
到。python allocate_setup.py
(如果你的python安装目录没有添加到你的路径中,这将不起作用 - 转到此处寻求帮助)Scripts
目录 (C:\Python27\Scripts
) 或添加该目录,如下所示以及 Python 基本安装目录到您的 %PATH% 环境变量中。easy_install pip
除非您位于
easy_install.exe
所在的目录 (C:\Python27\脚本将是 Python 2.7 的默认目录),或者您已将该目录添加到您的路径中。旧方法 1 使用 ez_setup:
来自 setuptools 页面 --
之后,您可以继续:
c:\Python2x\Scripts
到 Windows 路径(将Python2x
中的x
替换为您已安装的实际版本号)easy_install pip。
2014 UPDATE:
1) If you have installed Python 3.4 or later, pip is included with Python and should already be working on your system.
2) If you are running a version below Python 3.4 or if pip was not installed with Python 3.4 for some reason, then you'd probably use pip's official installation script
get-pip.py
. The pip installer now grabs setuptools for you, and works regardless of architecture (32-bit or 64-bit).The installation instructions are detailed here and involve:
I'll leave the two sets of old instructions below for posterity.
OLD Answers:
For Windows editions of the 64 bit variety - 64-bit Windows + Python used to require a separate installation method due to ez_setup, but I've tested the new distribute method on 64-bit Windows running 32-bit Python and 64-bit Python, and you can now use the same method for all versions of Windows/Python 2.7X:
OLD Method 2 using distribute:
C:\Python27\Scripts
(feel free to create aScripts
directory if it doesn't exist.cd
) to the directory you've downloadeddistribute_setup.py
to.python distribute_setup.py
(This will not work if your python installation directory is not added to your path - go here for help)Scripts
directory for your Python installation (C:\Python27\Scripts
) or add that directory, as well as the Python base installation directory to your %PATH% environment variable.easy_install pip
The last step will not work unless you're either in the directory
easy_install.exe
is located in (C:\Python27\Scripts would be the default for Python 2.7), or you have that directory added to your path.OLD Method 1 using ez_setup:
from the setuptools page --
After this, you may continue with:
c:\Python2x\Scripts
to the Windows path (replace thex
inPython2x
with the actual version number you have installed)easy_install pip
2016+ 更新:
这些答案已经过时或冗长且困难。
如果您使用的是 Python 3.4+ 或 2.7.9+,则为 Windows 上默认安装。否则,简而言之:
https://bootstrap.pypa.io/get-pip.py
(必须 b64 解码)。
get-pip.py
。或者,在资源管理器中右键单击其图标并选择“以管理员身份运行...”。新的二进制文件
pip.exe
(以及已弃用的easy_install.exe
)将位于"%ProgramFiles%\PythonXX\Scripts"
文件夹中(或类似的),通常不在您的 PATH 变量中。我建议添加它。2016+ Update:
These answers are outdated or otherwise wordy and difficult.
If you've got Python 3.4+ or 2.7.9+, it will be installed by default on Windows. Otherwise, in short:
https://bootstrap.pypa.io/get-pip.py
(must b64 decode).
get-pip.py
. Alternatively, right-click its icon in Explorer and choose the "run as Admin...".The new binaries
pip.exe
(and the deprecatedeasy_install.exe
) will be found in the"%ProgramFiles%\PythonXX\Scripts"
folder (or similar), which is often not in yourPATH
variable. I recommend adding it.Python 3.4 于 2014 年 3 月发布,附带
pip
:http://docs.python.org/3.4/whatsnew/3.4.html
因此,自从 Python 3.4 发布以来,在 Windows 上安装 pip 的最新方法是仅安装 Python。
推荐的使用方法是将其作为模块调用,尤其是在安装了多个 python 发行版或版本的情况下,以保证包到达正确的位置:
python -m pip install --upgrade packageXYZ
https://docs.python.org/3/installing/#work-with-multiple-versions-of-python-installed-in-parallel
Python 3.4, which was released in March 2014, comes with
pip
included:http://docs.python.org/3.4/whatsnew/3.4.html
So, since the release of Python 3.4, the up-to-date way to install pip on Windows is to just install Python.
The recommended way to use it is to call it as a module, especially with multiple python distributions or versions installed, to guarantee packages go to the correct place:
python -m pip install --upgrade packageXYZ
https://docs.python.org/3/installing/#work-with-multiple-versions-of-python-installed-in-parallel
当我必须使用 Windows 时,我使用 ActivePython,它会自动将所有内容添加到您的 PATH 中,并包含一个名为 PyPM< 的包管理器/a> 提供二进制包管理,使安装包更快更简单。
pip
和easy_install
并不完全相同,因此有些东西您可以通过pip
获得,但不能通过easy_install
获得代码> 反之亦然。我的建议是您获得 ActivePython Community Edition 并且不用担心获取所有内容的巨大麻烦在 Windows 上为 Python 设置。然后,您可以使用
pypm
。如果您想使用
pip
,您必须检查 ActiveState 安装程序中的PyPM
选项。安装完成后,您只需注销并再次登录,pip
将在命令行上可用,因为它包含在 ActiveState 安装程序PyPM
选项中,并且路径已设置安装程序已为您设置。PyPM
也将可用,但您不必使用它。When I have to use Windows, I use ActivePython, which automatically adds everything to your PATH and includes a package manager called PyPM which provides binary package management making it faster and simpler to install packages.
pip
andeasy_install
aren't exactly the same thing, so there are some things you can get throughpip
but noteasy_install
and vice versa.My recommendation is that you get ActivePython Community Edition and don't worry about the huge hassle of getting everything set up for Python on Windows. Then, you can just use
pypm
.In case you want to use
pip
you have to check thePyPM
option in the ActiveState installer. After installation you only need to logoff and log on again, andpip
will be available on the commandline, because it is contained in the ActiveState installerPyPM
option and the paths have been set by the installer for you already.PyPM
will also be available, but you do not have to use it.最新的方法是使用 Windows 的包管理器 Chocolatey。
安装完成后,您所要做的就是打开命令提示符并运行以下三个命令,这将安装 Python 2.7、easy_install 和 pip。它将自动检测您使用的是 x64 还是 x86 Windows。
Chocolatey Gallery 上的所有其他 Python 包都可以在此处找到。
The up-to-date way is to use Windows' package manager Chocolatey.
Once this is installed, all you have to do is open a command prompt and run the following the three commands below, which will install Python 2.7, easy_install and pip. It will automatically detect whether you're on x64 or x86 Windows.
All of the other Python packages on the Chocolatey Gallery can be found here.
2015 年 3 月更新
Python 2.7.9 及更高版本(在 Python 2 系列上)以及 Python 3.4 及更高版本默认包含 pip,因此您可能已经拥有 pip。
如果不这样做,请在提示符下运行这一行命令(可能需要管理员访问权限):
它将安装 pip 。如果尚未安装 Setuptools,
get-pip.py
将安装它也适合你。正如评论中提到的,上述命令将从 Pip 源代码存储库下载代码 GitHub,并且在您的环境中动态运行它。因此请注意,这是下载、检查和运行步骤的快捷方式,所有这些都使用 Python 本身的单个命令。如果您信任 Pip,请毫无疑问地继续。
确保您的 Windows 环境变量 PATH 包含 Python 的文件夹(对于 Python 2.7.x 默认安装:
C:\Python27
和C:\Python27\Scripts
,对于 Python 3.3x :C:\Python33
和C:\Python33\Scripts
等)。Update March 2015
Python 2.7.9 and later (on the Python 2 series), and Python 3.4 and later include pip by default, so you may have pip already.
If you don't, run this one line command on your prompt (which may require administrator access):
It will install pip. If Setuptools is not already installed,
get-pip.py
will install it for you too.As mentioned in comments, the above command will download code from the Pip source code repository at GitHub, and dynamically run it at your environment. So be noticed that this is a shortcut of the steps download, inspect and run, all with a single command using Python itself. If you trust Pip, proceed without doubt.
Be sure that your Windows environment variable PATH includes Python's folders (for Python 2.7.x default install:
C:\Python27
andC:\Python27\Scripts
, for Python 3.3x:C:\Python33
andC:\Python33\Scripts
, and so on).安装程序
我已经为 distribute 和 pip 此处(目标是使用
pip
,而无需使用easy_install
引导或保存并运行Python脚本):在 Windows 上,只需下载并安装首先从上述链接安装
distribute
,然后安装pip
。上面的distribute
链接确实包含存根.exe
安装程序,并且这些安装程序目前仅是 32 位。我没有在64位Windows上测试过效果。在 Windows 上构建
为新版本重做此过程并不困难,我将其包含在此处以供参考。
构建
distribute
为了获取存根
.exe
文件,您需要有一个 Visual C++ 编译器(它显然也可以与 MinGW 编译)构建
pip< /代码>
Installers
I've built Windows installers for both distribute and pip here (the goal being to use
pip
without having to either bootstrap witheasy_install
or save and run Python scripts):On Windows, simply download and install first
distribute
, thenpip
from the above links. Thedistribute
link above does contain stub.exe
installers, and these are currently 32-bit only. I haven't tested the effect on 64-bit Windows.Building on Windows
The process to redo this for new versions is not difficult, and I've included it here for reference.
Building
distribute
In order to get the stub
.exe
files, you need to have a Visual C++ compiler (it is apparently compilable with MinGW as well)Building
pip
以下适用于 Python 2.7。保存此脚本并启动它:
https://raw.github.com/pypa/pip/master /contrib/get-pip.py
Pip 已安装,然后将路径添加到您的环境:
最后
您还需要 Microsoft Visual C++ 2008 Express 要获得良好的编译器并在安装软件包时避免出现此类消息:
如果您有 64 位版本的 Windows 7,您可以阅读64 位 Windows 7 上的 64 位 Python 安装问题安装Python可执行包(注册表项问题)。
The following works for Python 2.7. Save this script and launch it:
https://raw.github.com/pypa/pip/master/contrib/get-pip.py
Pip is installed, then add the path to your environment :
Finally
Also you need Microsoft Visual C++ 2008 Express to get the good compiler and avoid these kind of messages when installing packages:
If you have a 64-bit version of Windows 7, you may read 64-bit Python installation issues on 64-bit Windows 7 to successfully install the Python executable package (issue with registry entries).
对于最新的 Python 下载 - 我在 Windows 上有 Python 3.6。你不必怀疑。您需要的一切都在那里。深吸一口气,我将向您展示如何操作。
确定您安装 Python 的位置。对我来说,它位于以下目录
<块引用>
现在,让我们将 Python 和 pip 添加到环境变量 path 设置中
如果您使用的是 Windows,则可以在任何地方键入
pip
或python
进行调用来自安装位置的
python
或pip
。因此,可以在上面屏幕的文件夹“SCRIPTS”下找到 PIP
让我们在环境变量 path 中添加 Python 和 PIP。
快完成了。让我们使用 CMD 进行测试,以使用 pip 安装 google 软件包。
For the latest Python download - I have Python 3.6 on Windows. You don't have to wonder. Everything you need is there. Take a breath, and I will show you how to do it.
Make sure where you install Python. For me, it was in the following directory
So, PIP is found under the folder in the above screen "SCRIPTS"
Let's add Python and PIP in the environment variable path.
Almost done. Let's test with CMD to install the google package using pip.
正如 Adrián 所说,要在 Python 2.x 上全局安装 pip,easy_install 似乎是最佳解决方案。
但是,pip 的 安装说明 建议使用 virtualenv 因为每个 virtualenv 都会自动安装 pip。这不需要 root 访问权限或修改系统 Python 安装。
不过安装 virtualenv 仍然需要 easy_install 。
2018 更新:
Python 3.3+ 现在包含 venv 模块 用于轻松创建虚拟环境,如下所示:
请参阅有关创建后激活环境的不同平台方法的文档,但通常是以下之一:
To install pip globally on Python 2.x, easy_install appears to be the best solution as Adrián states.
However the installation instructions for pip recommend using virtualenv since every virtualenv has pip installed in it automatically. This does not require root access or modify your system Python installation.
Installing virtualenv still requires easy_install though.
2018 update:
Python 3.3+ now includes the venv module for easily creating virtual environments like so:
See documentation for different platform methods of activating the environment after creation, but typically one of:
要使用 pip,并不强制要求您直接在系统中安装 pip。您可以通过
virtualenv
使用它。您可以执行以下步骤:我们通常需要为一个特定项目安装 Python 包。因此,现在创建一个项目文件夹,假设为 myproject。
virtualenv
解压文件夹中复制virtualenv.py文件,并将其粘贴到myproject文件夹中现在创建一个虚拟环境,假设 >myvirtualenv 如下,在 myproject 文件夹内:
它将显示:
现在您的虚拟环境 myvirtualenv 已在项目文件夹内创建。您可能会注意到,pip 现在已安装在您的虚拟环境中。您所需要做的就是使用以下命令激活虚拟环境。
您将在命令提示符处看到以下内容:
现在您可以开始使用 pip,但请确保您已激活 virtualenv(查看提示符左侧)。
这是在虚拟环境中安装 pip ie 最简单的方法之一,但您需要随身携带 virtualenv.py 文件。
更多安装 pip/virtualenv/virtualenvwrapper 的方法,可以参考 thegauraw.tumblr.com。
To use pip, it is not mandatory that you need to install pip in the system directly. You can use it through
virtualenv
. What you can do is follow these steps:We normally need to install Python packages for one particular project. So, now create a project folder, let’s say myproject.
virtualenv
, and paste inside the myproject folderNow create a virtual environment, let’s say myvirtualenv as follows, inside the myproject folder:
It will show you:
Now your virtual environment, myvirtualenv, is created inside your project folder. You might notice, pip is now installed inside you virtual environment. All you need to do is activate the virtual environment with the following command.
You will see the following at the command prompt:
Now you can start using pip, but make sure you have activated the virtualenv looking at the left of your prompt.
This is one of the easiest way to install pip i.e. inside virtual environment, but you need to have virtualenv.py file with you.
For more ways to install pip/virtualenv/virtualenvwrapper, you can refer to thegauraw.tumblr.com.
2016 年更新:
Pip
应该已包含在Python 2.7.9+ 或 3.4+
中,但如果出于某种原因它不存在,您可以使用以下一行。python get-pip.py
(如果您使用的是Linux,请使用sudo python get-pip.py
)PS:
这应该已经满足大多数情况下,但如有必要,请确保您的环境变量 PATH 包含 Python 的文件夹(例如 Windows 默认安装上的
Python 2.7.x
:C:\Python27 和 C:\Python27\脚本
,对于Python 3.3x
:C:\Python33 和 C:\Python33\Scripts
等)我遇到了同样的问题,然后发现了这样的问题最简单的方法(一个衬垫!)在官方网站上提到:http://www.pip-installer.org/en/latest/installing.html pip-installer.org/en/latest/installing.html
不能相信有很多冗长(也许已经过时?)的答案。对他们表示感谢,但是,请为这个简短的答案投票,以帮助更多的新人!
Updated at 2016 :
Pip
should already be included inPython 2.7.9+ or 3.4+
, but if for whatever reason it is not there, you can use the following one-liner.python get-pip.py
(If you are on Linux, usesudo python get-pip.py
)PS:
This should already be satisfied in most cases but, if necessary, be sure that your environment variable PATH includes Python's folders (for example,
Python 2.7.x
on Windows default install:C:\Python27 and C:\Python27\Scripts
, forPython 3.3x
:C:\Python33 and C:\Python33\Scripts
, etc)I encounter same problem and then found such perhaps easiest way (one liner!) mentioned on official website here: http://www.pip-installer.org/en/latest/installing.html
Can't believe there are so many lengthy (perhaps outdated?) answers out there. Feeling thankful to them but, please up-vote this short answer to help more new comers!
我只是想为那些在 Windows 64 位安装 setuptools 时遇到问题的人添加一种解决方案。这个问题在 python.org 上的这个 bug 中进行了讨论,并且截至本评论发表之日仍未解决。提到了一个简单的解决方法,并且它可以完美地工作。一项注册表更改对我来说起了作用。
链接: http://bugs.python.org/issue6792#
对我有用的解决方案... :
为 2.6+ 版本的 Python 添加此注册表设置:
这很可能是您已经拥有的 Python 2.6+ 注册表设置:
显然,您需要将 2.6 版本替换为您正在运行的任何版本的 Python。
I just wanted to add one more solution for those having issues installing setuptools from Windows 64-bit. The issue is discussed in this bug on python.org and is still unresolved as of the date of this comment. A simple workaround is mentioned and it works flawlessly. One registry change did the trick for me.
Link: http://bugs.python.org/issue6792#
Solution that worked for me...:
Add this registry setting for 2.6+ versions of Python:
This is most likely the registry setting you will already have for Python 2.6+:
Clearly, you will need to replace the 2.6 version with whatever version of Python you are running.
到目前为止,我发现的最好方法只是两行代码:
它是在 Windows 8 上使用 PowerShell、Cmd 和 Git Bash (MinGW)。
您可能想将路径添加到您的环境中。它位于类似
C:\Python33\Scripts
的位置。The best way I found so far, is just two lines of code:
It was tested on Windows 8 with PowerShell, Cmd, and Git Bash (MinGW).
And you probably want to add the path to your environment. It's somewhere like
C:\Python33\Scripts
.这是如何简单地安装 pip 的方法。
C:\Python27
。C:\Python27\Scripts
路径添加到环境变量中。因为它包含pip.exe
文件。cmd
并输入pip install package_name
Here how to install pip the easy way.
C:\Python27
.C:\Python27\Scripts
path to your environment variable. Because it includes thepip.exe
file.cmd
and type aspip install package_name
PythonXY 附带了
pip
,其中 其他。PythonXY comes with
pip
included, among others.我在 Windows 上使用来自 Continum.io 的跨平台 Anaconda 包管理器,它很可靠。它具有虚拟环境管理和功能齐全的外壳以及常用实用程序(例如 conda、pip)。
conda
还附带了具有非 Python 依赖项的库的二进制文件,例如pandas
、numpy
等。这在 Windows 上尤其有用,因为它可以很难正确编译 C 依赖项。I use the cross-platform Anaconda package manager from continuum.io on Windows and it is reliable. It has virtual environment management and a fully featured shell with common utilities (e.g. conda, pip).
conda
also comes with binaries for libraries with non-Python dependencies, e.g.pandas
,numpy
, etc. This proves useful particularly on Windows as it can be hard to correctly compile C dependencies.当我按照此处的说明进行操作时,我在以不同方式安装时遇到了一些问题。我认为以同样的方式在每个 Windows 环境中安装是非常棘手的。就我而言,我需要在同一台机器上安装 Python 2.6、2.7 和 3.3 以用于不同的目的,因此我认为存在更多问题。
但以下说明对我来说非常有效,因此可能取决于您的环境,您应该尝试这个:
http://docs.python-guide.org/en/latest/starting/install/win/
另外,由于环境不同,我发现使用虚拟环境非常有用,我有使用不同库的网站,最好将它们封装到一个文件夹中,请查看说明,简要说明如果安装了 PIP,则只需安装 VirtualEnv:
在运行所有文件的文件夹中
几秒钟后,您将拥有一个虚拟环境venv 文件夹中的所有内容,要激活它,请运行 venv/Scripts/activate.bat (停用环境很容易,使用 deactivate.bat)。您安装的每个库最终都会位于 venv\Lib\site-packages 中,并且可以轻松地将整个环境移动到某个地方。
我发现的唯一缺点是某些代码编辑器无法识别这种环境,并且您会在代码中看到警告,因为找不到导入的库。当然,有一些棘手的方法可以做到这一点,但编辑者最好记住虚拟环境现在很常见。
希望有帮助。
I had some issues installing in different ways when I followed instructions here. I think it's very tricky to install in every Windows environment in the same way. In my case I need Python 2.6, 2.7 and 3.3 in the same machine for different purposes so that's why I think there're more problems.
But the following instructions worked perfectly for me, so might be depending on your environment you should try this one:
http://docs.python-guide.org/en/latest/starting/install/win/
Also, due to the different environments I found incredible useful to use Virtual Environments, I had websites that use different libraries and it's much better to encapsulate them into a single folder, check out the instructions, briefly if PIP is installed you just install VirtualEnv:
Into the folder you have all your files run
And seconds later you have a virtual environment with everything in venv folder, to activate it run venv/Scripts/activate.bat (deactivate the environment is easy, use deactivate.bat). Every library you install will end up in venv\Lib\site-packages and it's easy to move your whole environment somewhere.
The only downside I found is some code editors can't recognize this kind of environments, and you will see warnings in your code because imported libraries are not found. Of course there're tricky ways to do it but it would be nice editors keep in mind Virtual Environments are very normal nowadays.
Hope it helps.
指南链接:http://www.pip-installer.org/ en/latest/installing.html#install-pip
注意:确保像这样的脚本路径 (C:\Python27\Scripts) 也添加到 int %PATH% 环境变量中。
Guide link: http://www.pip-installer.org/en/latest/installing.html#install-pip
Note: Make sure scripts path like this (C:\Python27\Scripts) is added int %PATH% environment variable as well.
非常简单:(
确保您的 Python 和 Python 脚本目录(例如,
C:\Python27
和C:\Python27\Scripts
)位于 PATH 中。)It's very simple:
(Make sure your Python and Python script directory (for example,
C:\Python27
andC:\Python27\Scripts
) are in the PATH.)自 2014 年 2 月 4 日开始工作:):
如果您尝试通过 http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip 正如@Colonel Panic所建议的,您可能已经成功安装了pip包管理器,但您可能无法安装任何带有 pip 的包。您可能也遇到了与我尝试安装 Beautiful Soup 4 时遇到的相同的 SSL 错误如果您查看 pip.log 文件:
问题是旧版本的 OpenSSL 的问题与 pip 1.3.1 及以上版本不兼容。目前最简单的解决方法是安装 pip 1.2.1,它不需要 SSL
: Windows 上的 Pip:
python setup.py install
C:\Python27\Scripts
是在 PATH 中,因为 pip 安装在C:\Python27\Scripts
目录中,与通常安装 Python 包的C:\Python27\Lib\site-packages
目录不同现在尝试安装任何使用 pip 的包。
例如,要使用 pip 安装
requests
包,请从 cmd 运行以下命令:Whola!
requests
将成功安装,您将收到一条成功消息。Working as of Feb 04 2014 :):
If you have tried installing pip through the Windows installer file from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip as suggested by @Colonel Panic, you might have installed the pip package manager successfully, but you might be unable to install any packages with pip. You might also have got the same SSL error as I got when I tried to install Beautiful Soup 4 if you look in the pip.log file:
The problem is an issue with an old version of OpenSSL being incompatible with pip 1.3.1 and above versions. The easy workaround for now, is to install pip 1.2.1, which does not require SSL:
Installing Pip on Windows:
cd <path to extracted folder>/pip-1.2.1
python setup.py install
C:\Python27\Scripts
is in PATH because pip is installed in theC:\Python27\Scripts
directory unlikeC:\Python27\Lib\site-packages
where Python packages are normally installedNow try to install any package using pip.
For example, to install the
requests
package using pip, run this from cmd:Whola!
requests
will be successfully installed and you will get a success message.简单CMD方式
使用CURL下载get-pip.py:
执行下载的Python文件
然后将
C:\Python37\Scripts
路径添加到环境变量中。 假设您的 C 盘中有一个Python37
文件夹。该文件夹名称可能会根据安装的 Python 版本而有所不同现在您可以通过运行来安装 Python 包
Simple CMD way
Use CURL to download get-pip.py:
Execute the downloaded Python file
Then add
C:\Python37\Scripts
path to your environment variable. It assumes that there is aPython37
folder in your C drive. That folder name may vary according to the installed Python versionNow you can install Python packages by running
如果您使用的是从 python.org,但您需要升级 pip。
在 Windows 上,升级可以轻松完成:
转到 Python 命令行并运行以下 Python 命令
使用 get-pip.py 安装
下载 get-pip.py 位于同一文件夹或您选择的任何其他文件夹中。我假设您将其下载到包含 python.exe 文件的同一文件夹中并运行此命令:
Pip 的 安装指南非常干净简单。
使用它,您应该能够在两分钟内开始使用 Pip。
pip is already installed if you're using Python 2 >= 2.7.9 or Python 3 >= 3.4 binaries downloaded from python.org, but you'll need to upgrade pip.
On Windows, the upgrade can be done easily:
Go to a Python command line and run the below Python command
Installing with get-pip.py
Download get-pip.py in the same folder or any other folder of your choice. I am assuming you will download it in the same folder from where you have the python.exe file and run this command:
Pip's installation guide is pretty clean and simple.
Using this, you should be able to get started with Pip in under two minutes.
安装适用于 Python 2 和 Python 3 的 Pip
python get-pip.py
、python3 get-pip.py
或python3.6 get-pip.py
,具体取决于您想要在哪个版本的 Python 上安装pip
旧答案(仍然有效)
尝试:
这可能是在任何系统上安装 pip 的最简单方法。
Installing Pip for Python 2 and Python 3
get-pip.py
.python get-pip.py
,python3 get-pip.py
orpython3.6 get-pip.py
, depending on which version of Python you want to installpip
Old answer (still valid)
Try:
It's probably the easiest way to install pip on any system.
如果您的 pip 版本还有其他问题,您可以尝试以下操作:
If you even have other problems with the pip version, you can try this:
现在,它与 Python 捆绑在一起。您不需要安装它。
这是检查 pip 是否安装的方法。
在极少数情况下,如果未安装,请下载 get-pip.py 文件并使用 Python 运行它
Now, it is bundled with Python. You don't need to install it.
This is how you can check whether pip is installed or not.
In rare cases, if it is not installed, download the get-pip.py file and run it with Python as
我认为这个问题让答案看起来比实际情况更简单。
运行 pip 有时需要对模块进行本机编译(64 位 NumPy 是一个常见的示例)。为了使 pip 编译成功,您需要使用与 pip 所使用的 Microsoft Visual C++ 版本相同的 Python 进行编译。
标准 Python 发行版使用 Microsoft Visual C++ 2008 进行编译。您可以安装 Microsoft Visual C++ 2008 的 Express 版本,但不对其进行维护。最好的选择是获取更高版本的 Microsoft Visual C++ 的 Express 版本并编译 Python。然后 PIP 和 Python 将使用相同的 Microsoft Visual C++ 版本。
I think the question makes it seem like the answer is simpler than it really is.
Running of pip will sometimes require native compilation of a module (64-bit NumPy is a common example of that). In order for pip's compilation to succeed, you need Python which was compiled with the same version of Microsoft Visual C++ as the one pip is using.
Standard Python distributions are compiled with Microsoft Visual C++ 2008. You can install an Express version of Microsoft Visual C++ 2008, but it is not maintained. Your best bet is to get an express version of a later Microsoft Visual C++ and compile Python. Then PIP and Python will be using the same Microsoft Visual C++ version.
Windows 10 更新 - 仅 GUI
从现在起您只需访问 Microsoft Store,然后查找 Python:
哪个功能:
这是在 Windows 上安装 python 和 pip 最简单、最安全的方法。
Windows 10 Update - GUI only
From now on you can just access Microsoft Store, and look for Python:
Which feature:
That's the easiest and safest way to install python and pip on windows.