标签归档:easy-install

为什么要在easy_install上使用pip?[关闭]

问题:为什么要在easy_install上使用pip?[关闭]

一条推文中写道:

不要使用easy_install,除非您喜欢对自己的脸部进行刺伤。使用点子。

为什么要在easy_install上使用pip?难道不是PyPI和程序包作者最主要的原因吗?如果作者将废话源tarball(例如:缺少文件,没有setup.py)上传到PyPI,则pip和easy_install都将失败。除了化妆品的差异,为什么Python的人(如上面的鸣叫)似乎强烈地倾向于在点子的easy_install?

(假设我们正在谈论由社区维护的Distribute软件包中的easy_install)

A tweet reads:

Don’t use easy_install, unless you like stabbing yourself in the face. Use pip.

Why use pip over easy_install? Doesn’t the fault lie with PyPI and package authors mostly? If an author uploads crap source tarball (eg: missing files, no setup.py) to PyPI, then both pip and easy_install will fail. Other than cosmetic differences, why do Python people (like in the above tweet) seem to strongly favor pip over easy_install?

(Let’s assume that we’re talking about easy_install from the Distribute package, that is maintained by the community)


回答 0

此处的许多答案在2015年已经过时了(尽管最初由Daniel Roseman接受的答案不是)。这是当前的状态:

  • 现在,二进制程序包以轮子(.whl文件)的形式分发-不仅在PyPI上,而且在第三方存储库中,例如Christoph Gohlke的Windows Extension Packagespip可以处理轮子;easy_install不能。
  • 虚拟环境(由3.4内置,或者可以通过2.6添加到2.6 + / 3.1 + virtualenv)已经成为一个非常重要和突出的工具(并在官方文档中推荐);它们pip是开箱即用的,但是甚至无法正常使用easy_install
  • distribute包含的软件包easy_install不再维护。它的改进已setuptools合并回setuptools。尝试安装distribute只会安装setuptools
  • easy_install 本身只是准维护的。
  • 所有的其中箱子pip用于不如easy_install从解包源树-installing,从DVCS回购等-是早已过去的; 你可以pip install .pip install git+https://
  • pip带有来自python.org的官方Python 2.7和3.4+软件包,pip如果您从源代码构建,则默认情况下会包含引导程序。
  • Python打包用户指南》已取代了有关安装,使用和构建软件包的各种文档的不完整之处。现在,Python自己的有关安装Python模块的文档符合该用户指南的要求,并明确地pip称为“首选安装程序”。
  • pip这些年来,还添加了其他新功能,这些功能将永远不会存在easy_install。例如,pip通过构建需求文件,然后在每一侧使用单个命令安装它,可以轻松克隆站点程序包。或将您的需求文件转换为本地回购以用于内部开发。等等。

我知道easy_install在2015年使用的唯一好的理由是在OS X 10.5-10.8中使用Apple预先安装的Python版本的特殊情况。从10.5开始,Apple已包含easy_install,但从10.10开始,它们仍然不包含pip。使用10.9+时,您仍然应该只使用get-pip.py,但是对于10.5-10.8,这存在一些问题,因此更容易实现sudo easy_install pip。(通常,这easy_install pip是一个坏主意;您只想在OS X 10.5-10.8上才能做到这一点。)此外,10.5-10.8包含readline以一种easy_install知道如何纠缠而pip不会纠缠的方式,因此您也想sudo easy_install readline如果要升级。

Many of the answers here are out of date for 2015 (although the initially accepted one from Daniel Roseman is not). Here’s the current state of things:

  • Binary packages are now distributed as wheels (.whl files)—not just on PyPI, but in third-party repositories like Christoph Gohlke’s Extension Packages for Windows. pip can handle wheels; easy_install cannot.
  • Virtual environments (which come built-in with 3.4, or can be added to 2.6+/3.1+ with virtualenv) have become a very important and prominent tool (and recommended in the official docs); they include pip out of the box, but don’t even work properly with easy_install.
  • The distribute package that included easy_install is no longer maintained. Its improvements over setuptools got merged back into setuptools. Trying to install distribute will just install setuptools instead.
  • easy_install itself is only quasi-maintained.
  • All of the cases where pip used to be inferior to easy_install—installing from an unpacked source tree, from a DVCS repo, etc.—are long-gone; you can pip install ., pip install git+https://.
  • pip comes with the official Python 2.7 and 3.4+ packages from python.org, and a pip bootstrap is included by default if you build from source.
  • The various incomplete bits of documentation on installing, using, and building packages have been replaced by the Python Packaging User Guide. Python’s own documentation on Installing Python Modules now defers to this user guide, and explicitly calls out pip as “the preferred installer program”.
  • Other new features have been added to pip over the years that will never be in easy_install. For example, pip makes it easy to clone your site-packages by building a requirements file and then installing it with a single command on each side. Or to convert your requirements file to a local repo to use for in-house development. And so on.

The only good reason that I know of to use easy_install in 2015 is the special case of using Apple’s pre-installed Python versions with OS X 10.5-10.8. Since 10.5, Apple has included easy_install, but as of 10.10 they still don’t include pip. With 10.9+, you should still just use get-pip.py, but for 10.5-10.8, this has some problems, so it’s easier to sudo easy_install pip. (In general, easy_install pip is a bad idea; it’s only for OS X 10.5-10.8 that you want to do this.) Also, 10.5-10.8 include readline in a way that easy_install knows how to kludge around but pip doesn’t, so you also want to sudo easy_install readline if you want to upgrade that.


回答 1

从伊恩·比金(Ian Bicking)自己对pip介绍

pip最初旨在通过以下方式对easy_install进行改进

  • 所有软件包均在安装前已下载。结果不会发生部分完成的安装。
  • 注意在控制台上显示有用的输出。
  • 采取行动的原因已被跟踪。例如,如果正在安装软件包,则pip会跟踪为什么需要该软件包。
  • 错误消息应该很有用。
  • 该代码相对简洁明了,具有内聚性,可以更轻松地以编程方式使用。
  • 软件包不必作为Egg存档安装,可以将它们平放安装(同时保留Egg元数据)。
  • 对其他版本控制系统(Git,Mercurial和Bazaar)的本地支持
  • 卸载软件包。
  • 简单定义固定的需求集并可靠地复制一组包。

From Ian Bicking’s own introduction to pip:

pip was originally written to improve on easy_install in the following ways

  • All packages are downloaded before installation. Partially-completed installation doesn’t occur as a result.
  • Care is taken to present useful output on the console.
  • The reasons for actions are kept track of. For instance, if a package is being installed, pip keeps track of why that package was required.
  • Error messages should be useful.
  • The code is relatively concise and cohesive, making it easier to use programmatically.
  • Packages don’t have to be installed as egg archives, they can be installed flat (while keeping the egg metadata).
  • Native support for other version control systems (Git, Mercurial and Bazaar)
  • Uninstallation of packages.
  • Simple to define fixed sets of requirements and reliably reproduce a set of packages.

回答 2

另一个(至今尚未提及)之所以喜欢点子,是因为它是新的热点,并将在未来继续使用。

以下信息图表(来自《The Hitchhiker’s Guide to Packaging v1.0》中的包装当前状态”部分)表明setuptools / easy_install将来会消失。

这是Distribution的文档中的另一个信息图,显示Setuptools和easy_install将被新的热点— distributionpip取代。虽然PIP仍然是新的辣味,分发与合并的setuptools在2013年发布的setuptools V0.7。

Another—as of yet unmentioned—reason for favoring pip is because it is the new hotness and will continue to be used in the future.

The infographic below—from the Current State of Packaging section in the The Hitchhiker’s Guide to Packaging v1.0—shows that setuptools/easy_install will go away in the future.

Here’s another infographic from distribute’s documentation showing that Setuptools and easy_install will be replaced by the new hotness—distribute and pip. While pip is still the new hotness, Distribute merged with Setuptools in 2013 with the release of Setuptools v0.7.


回答 3

有两个原因,可能还有更多:

  1. pip提供uninstall命令

  2. 如果中间安装失败,则pip将使您保持干净状态。

Two reasons, there may be more:

  1. pip provides an uninstall command

  2. if an installation fails in the middle, pip will leave you in a clean state.


回答 4

需求文件。

认真地说,我每天都将它与virtualenv结合使用。


快速依赖管理教程,民谣

需求文件使您可以创建已通过pip安装的所有软件包的快照。通过将这些程序包封装在虚拟环境中,可以使代码库在一组非常特定的程序包中工作,并与其他人共享该代码库。

从Heroku的文档中 https://devcenter.heroku.com/articles/python

您创建一个虚拟环境,并设置您的外壳以使用它。(bash / * nix指令)

virtualenv env
source env/bin/activate

现在,与此外壳一起运行的所有python脚本都将使用该环境的软件包和配置。现在,您可以在此环境中本地安装软件包,而无需在计算机上全局安装。

pip install flask

现在,您可以转储有关安装哪些软件包的信息

pip freeze > requirements.txt

如果您将该文件签入版本控制中,那么当其他人获取您的代码时,他们可以设置自己的虚拟环境并使用以下命令安装所有依赖项:

pip install -r requirements.txt

任何时候您都可以像这样自动执行乏味的操作。

REQUIREMENTS files.

Seriously, I use this in conjunction with virtualenv every day.


QUICK DEPENDENCY MANAGEMENT TUTORIAL, FOLKS

Requirements files allow you to create a snapshot of all packages that have been installed through pip. By encapsulating those packages in a virtualenvironment, you can have your codebase work off a very specific set of packages and share that codebase with others.

From Heroku’s documentation https://devcenter.heroku.com/articles/python

You create a virtual environment, and set your shell to use it. (bash/*nix instructions)

virtualenv env
source env/bin/activate

Now all python scripts run with this shell will use this environment’s packages and configuration. Now you can install a package locally to this environment without needing to install it globally on your machine.

pip install flask

Now you can dump the info about which packages are installed with

pip freeze > requirements.txt

If you checked that file into version control, when someone else gets your code, they can setup their own virtual environment and install all the dependencies with:

pip install -r requirements.txt

Any time you can automate tedium like this is awesome.


回答 5

pip不会安装二进制软件包,并且未在Windows上经过良好测试。

由于Windows默认没有附带编译器,因此通常无法在其中使用pip 。easy_install 可以为Windows安装二进制软件包。

pip won’t install binary packages and isn’t well tested on Windows.

As Windows doesn’t come with a compiler by default pip often can’t be used there. easy_install can install binary packages for Windows.


回答 6

更新:正如某些人所想,setuptools已经吸收distribute了相反的东西。setuptools是最新的最新distutils更改和滚轮格式。因此,easy_installpip或多或少平等现在。

来源:http : //pythonhosted.org/setuptools/merge-faq.html#why-setuptools-and-not-distribute-or-another-name

UPDATE: setuptools has absorbed distribute as opposed to the other way around, as some thought. setuptools is up-to-date with the latest distutils changes and the wheel format. Hence, easy_install and pip are more or less on equal footing now.

Source: http://pythonhosted.org/setuptools/merge-faq.html#why-setuptools-and-not-distribute-or-another-name


回答 7

除了模糊人的答复:

pip不会安装二进制软件包,并且未在Windows上经过良好测试。

由于Windows默认不带编译器,因此通常无法在其中使用pip。easy_install可以为Windows安装二进制软件包。

这是Windows上的一个技巧:

  • 您可以使用easy_install <package>安装二进制软件包来避免生成二进制文件

  • pip uninstall <package>即使您使用过easy_install,也可以使用 。

这只是在Windows上对我有效的解决方法。实际上,如果不涉及二进制文件,我总是使用pip。

请参阅当前的pip doku:http://www.pip-installer.org/en/latest/other-tools.html#pip-compared-to-easy-install

我将在邮件列表中询问为此计划的内容。

这是最新的更新:

新的受支持的安装二进制文件的方式将是wheel!它尚未在标准中,但几乎已经存在。当前版本仍为Alpha:1.0.0a1

https://pypi.python.org/pypi/wheel

http://wheel.readthedocs.org/en/latest/

我将wheel通过创建要PySide使用的OS X安装程序进行测试wheel,而不是蛋。会回来并报告此情况。

欢呼声-克里斯

快速更新:

到的过渡wheel即将结束。大多数软件包都支持wheel

我答应为制作车轮PySide,去年夏天我做了。很棒!

提示:一些开发商至今未能支撑轮格式,仅仅是因为他们忘记更换distutilssetuptools。通常,通过替换中的单个单词很容易转换此类软件包setup.py

As an addition to fuzzyman’s reply:

pip won’t install binary packages and isn’t well tested on Windows.

As Windows doesn’t come with a compiler by default pip often can’t be used there. easy_install can install binary packages for Windows.

Here is a trick on Windows:

  • you can use easy_install <package> to install binary packages to avoid building a binary

  • you can use pip uninstall <package> even if you used easy_install.

This is just a work-around that works for me on windows. Actually I always use pip if no binaries are involved.

See the current pip doku: http://www.pip-installer.org/en/latest/other-tools.html#pip-compared-to-easy-install

I will ask on the mailing list what is planned for that.

Here is the latest update:

The new supported way to install binaries is going to be wheel! It is not yet in the standard, but almost. Current version is still an alpha: 1.0.0a1

https://pypi.python.org/pypi/wheel

http://wheel.readthedocs.org/en/latest/

I will test wheel by creating an OS X installer for PySide using wheel instead of eggs. Will get back and report about this.

cheers – Chris

A quick update:

The transition to wheel is almost over. Most packages are supporting wheel.

I promised to build wheels for PySide, and I did that last summer. Works great!

HINT: A few developers failed so far to support the wheel format, simply because they forget to replace distutils by setuptools. Often, it is easy to convert such packages by replacing this single word in setup.py.


回答 8

刚遇到一个我不得不easy_install代替的特殊情况pip,否则我必须直接提取源代码。

对于该软件包GitPython,in中的版本pip太旧,即0.1.7,而from中的版本easy_install是最新的,即0.3.2.rc1

我正在使用Python 2.7.8。我不知道有关的底层机制easy_installpip,但至少有一些包的版本可能是彼此不同的,有时easy_install是一个较新的版本。

easy_install GitPython

Just met one special case that I had to use easy_install instead of pip, or I have to pull the source codes directly.

For the package GitPython, the version in pip is too old, which is 0.1.7, while the one from easy_install is the latest which is 0.3.2.rc1.

I’m using Python 2.7.8. I’m not sure about the underlay mechanism of easy_install and pip, but at least the versions of some packages may be different from each other, and sometimes easy_install is the one with newer version.

easy_install GitPython

如何删除使用Python的easy_install安装的软件包?

问题:如何删除使用Python的easy_install安装的软件包?

Python easy_install使安装新软件包非常方便。但是,据我所知,它没有实现依赖项管理器的其他常见功能-列出和删除已安装的软件包。

找出已安装的软件包的最佳方法是什么,以及删除已安装软件包的首选方法是什么?如果我手动(例如,通过rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg类似方式)删除软件包,是否需要更新任何文件?

Python’s easy_install makes installing new packages extremely convenient. However, as far as I can tell, it doesn’t implement the other common features of a dependency manager – listing and removing installed packages.

What is the best way of finding out what’s installed, and what is the preferred way of removing installed packages? Are there any files that need to be updated if I remove packages manually (e.g. by rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg or similar)?


回答 0

pip是setuptools / easy_install的替代产品,提供了“卸载”命令。

根据安装说明安装pip :

$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py

然后,您可以使用pip uninstall删除与easy_install

pip, an alternative to setuptools/easy_install, provides an “uninstall” command.

Install pip according to the installation instructions:

$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py

Then you can use pip uninstall to remove packages installed with easy_install


回答 1

要卸载,.egg您需要rm -rf鸡蛋(可能是目录)并从中删除匹配的行site-packages/easy-install.pth

To uninstall an .egg you need to rm -rf the egg (it might be a directory) and remove the matching line from site-packages/easy-install.pth


回答 2

首先,您必须运行以下命令:

$ easy_install -m [PACKAGE]

它删除了程序包的所有依赖项。

然后删除该包装的鸡蛋文件:

$ sudo rm -rf /usr/local/lib/python2.X/site-packages/[PACKAGE].egg

First you have to run this command:

$ easy_install -m [PACKAGE]

It removes all dependencies of the package.

Then remove egg file of that package:

$ sudo rm -rf /usr/local/lib/python2.X/site-packages/[PACKAGE].egg

回答 3

所有的信息在其他的答案,但没有总结两者的请求,或者似乎使事情不必要的复杂性:

  • 对于您的搬迁需求,请使用:

    pip uninstall <package>

    (使用安装easy_install pip

  • 对于“列出已安装的软件包”,需要使用以下任一方法:

    pip freeze

    要么:

    yolk -l

    可以输出更多包装详细信息。

    (通过easy_install yolk或安装pip install yolk

All the info is in the other answers, but none summarizes both your requests or seem to make things needlessly complex:

  • For your removal needs use:

    pip uninstall <package>
    

    (install using easy_install pip)

  • For your ‘list installed packages’ needs either use:

    pip freeze
    

    Or:

    yolk -l
    

    which can output more package details.

    (Install via easy_install yolk or pip install yolk)


回答 4

网上有多个消息源建议通过使用-m选项重新安装软件包,然后仅删除lib /中的.egg文件和bin /中的二进制文件来破解。另外,可以在python bug跟踪器上找到有关setuptools问题的讨论,名称为setuptools issue 21

编辑:将链接添加到python bugtracker。

There are several sources on the net suggesting a hack by reinstalling the package with the -m option and then just removing the .egg file in lib/ and the binaries in bin/. Also, discussion about this setuptools issue can be found on the python bug tracker as setuptools issue 21.

Edit: Added the link to the python bugtracker.


回答 5

如果问题严重困扰您,您可以考虑使用virtualenv。它允许您创建一个封装python库的环境。您在此处而不是在全局site-packages目录中安装软件包。您在该环境中运行的所有脚本都可以访问这些程序包(也可以选择全局程序包)。在评估不确定/是否需要全局安装的软件包时,我经常使用此工具。如果您决定不需要该软件包,那么将虚拟环境吹走就很容易了。它很容易使用。制作一个新的环境:

$>virtualenv /path/to/your/new/ENV

virtual_envt在新环境中为您安装setuptools,因此您可以执行以下操作:

$>ENV/bin/easy_install

您甚至可以创建自己的boostrap脚本来设置新环境。因此,使用一个命令,您可以创建一个新的虚拟环境,例如默认安装了python 2.6,psycopg2和django(如果需要,您可以安装特定于环境的python版本)。

If the problem is a serious-enough annoyance to you, you might consider virtualenv. It allows you to create an environment that encapsulates python libraries. You install packages there rather than in the global site-packages directory. Any scripts you run in that environment have access to those packages (and optionally, your global ones as well). I use this a lot when evaluating packages that I am not sure I want/need to install globally. If you decide you don’t need the package, it’s easy enough to just blow that virtual environment away. It’s pretty easy to use. Make a new env:

$>virtualenv /path/to/your/new/ENV

virtual_envt installs setuptools for you in the new environment, so you can do:

$>ENV/bin/easy_install

You can even create your own boostrap scripts that setup your new environment. So, with one command, you can create a new virtual env with, say, python 2.6, psycopg2 and django installed by default (you can can install an env-specific version of python if you want).


回答 6

官方说明?:http : //peak.telecommunity.com/DevCenter/EasyInstall#uninstalling-packages

如果您用其他版本替换了软件包,则可以通过删除PackageName-versioninfo.egg文件或目录(位于安装目录中)来删除不需要的软件包。

如果要删除软件包的当前安装版本(或软件包的所有版本),则应首先运行:

easy_install -mxN PackageName

这样可以确保Python不会继续搜索您打算删除的软件包。完成此操作后,您可以安全地删除.egg文件或目录以及要删除的所有脚本。

Official(?) instructions: http://peak.telecommunity.com/DevCenter/EasyInstall#uninstalling-packages

If you have replaced a package with another version, then you can just delete the package(s) you don’t need by deleting the PackageName-versioninfo.egg file or directory (found in the installation directory).

If you want to delete the currently installed version of a package (or all versions of a package), you should first run:

easy_install -mxN PackageName

This will ensure that Python doesn’t continue to search for a package you’re planning to remove. After you’ve done this, you can safely delete the .egg files or directories, along with any scripts you wish to remove.


回答 7

尝试

$ easy_install -m [PACKAGE]

然后

$ rm -rf .../python2.X/site-packages/[PACKAGE].egg

try

$ easy_install -m [PACKAGE]

then

$ rm -rf .../python2.X/site-packages/[PACKAGE].egg

回答 8

要列出已安装的Python软件包,可以使用yolk -l。不过,您需要先使用easy_install yolk

To list installed Python packages, you can use yolk -l. You’ll need to use easy_install yolk first though.


回答 9

在尝试卸载随时间推移而安装的许多随机Python软件包时遇到了这个问题。

使用此线程中的信息,这是我想到的:

cat package_list | xargs -n1 sudo pip uninstall -y

package_list从清理(AWK)pip freeze中的virtualenv。

要删除几乎所有的Python软件包:

yolk -l | cut -f 1 -d " " | grep -v "setuptools|pip|ETC.." | xargs -n1 pip uninstall -y

Came across this question, while trying to uninstall the many random Python packages installed over time.

Using information from this thread, this is what I came up with:

cat package_list | xargs -n1 sudo pip uninstall -y

The package_list is cleaned up (awk) from a pip freeze in a virtualenv.

To remove almost all Python packages:

yolk -l | cut -f 1 -d " " | grep -v "setuptools|pip|ETC.." | xargs -n1 pip uninstall -y

回答 10

我在MacOS X Leopard 10.6.blah上遇到了同样的问题。

解决方案是确保您正在调用MacPorts Python:

sudo port install python26
sudo port install python_select
sudo python_select python26
sudo port install py26-mysql

希望这可以帮助。

I ran into the same problem on my MacOS X Leopard 10.6.blah.

Solution is to make sure you’re calling the MacPorts Python:

sudo port install python26
sudo port install python_select
sudo python_select python26
sudo port install py26-mysql

Hope this helps.


回答 11

对我而言,仅删除此文件:easy-install.pth有效,其余pip install django == 1.3.7

For me only deleting this file : easy-install.pth worked, rest pip install django==1.3.7


回答 12

这对我有用。它与先前的答案相似,但打包的路径不同。

  1. 须藤easy_install -m
  2. 须藤rm -rf /Library/Python/2.7/site-packages/.egg

平台:MacOS High Sierra版本10.13.3

This worked for me. It’s similar to previous answers but the path to the packages is different.

  1. sudo easy_install -m
  2. sudo rm -rf /Library/Python/2.7/site-packages/.egg

Plaform: MacOS High Sierra version 10.13.3


如何在Windows上安装pip?

问题:如何在Windows上安装pip?

pip是的替代品easy_install。但是我应该在Windows上pip使用安装easy_install吗?有没有更好的办法?

pip is a replacement for easy_install. But should I install pip using easy_install on Windows? Is there a better way?


回答 0

Python 2.7.9+和3.4+

好消息!Pip随附了Python 3.4(2014年3月发布)和Python 2.7.9(2014年12月发布)。这是所有Python版本中的最佳功能。它使每个人都可以访问社区丰富的图书馆。新手不再因设置的困难而无法使用社区库。在与软件包管理器一起交付时,Python加入了RubyNode.jsHaskellPerlGo以及几乎所有其他具有主流开源社区的当代语言。谢谢,Python。

如果确实发现在使用Python 3.4+或Python 2.7.9+时不可用pip,则只需执行例如:

py -3 -m ensurepip

当然,这并不意味着Python打包已解决问题。经验仍然令人沮丧。我将在“堆栈溢出”问题中对此进行讨论。Python是否具有程序包/模块管理系统?

而且,对使用Python 2.7.8或更早版本(社区中相当大的一部分)的每个人来说都可惜。没有计划将Pip运送给您。遵循手册说明。

Python 2≤2.7.8和Python 3≤3.3

面对“包括电池”的座右铭,Python出厂时没有软件包管理器。更糟糕的是,直到最近,Pip一直很难安装。

官方指示

根据https://pip.pypa.io/zh-CN/stable/installing/#do-i-need-to-install-pip

下载时get-pip.py,请小心保存为.py文件而不是文件.txt。然后,在命令提示符下运行它:

python get-pip.py

您可能需要管理员命令提示符才能执行此操作。按照以管理员身份启动命令提示符(Microsoft TechNet)。

这将安装pip程序包,该程序包(在Windows中)包含… \ Scripts \ pip.exe,该路径必须位于PATH环境变量中才能从命令行使用pip(请参阅“替代说明”的第二部分,将其添加到您的路径,

替代说明

官方文档告诉用户从源代码安装Pip及其每个依赖项。对于新手来说,这是乏味的,对新手来说却是困难重重。

为了我们的缘故,Christoph Gohlke .msi为流行的Python软件包准备了Windows安装程序()。他为所有32位和64位Python版本构建安装程序。你需要:

  1. 安装setuptools
  2. 安装点子

对我来说,此安装点位于C:\Python27\Scripts\pip.exepip.exe在您的计算机上查找,然后将其文件夹(例如C:\Python27\Scripts)添加到您的路径(开始/编辑环境变量)。现在,您应该可以从命令行运行pip了。尝试安装软件包:

pip install httpie

你去了(希望)!常见问题的解决方案如下:

代理问题

如果您在办公室工作,则可能位于HTTP代理后面。如果是这样,请设置环境变量http_proxyhttps_proxy。大多数Python应用程序(和其他免费软件)都遵守这些规定。语法示例:

http://proxy_url:port
http://username:password@proxy_url:port

如果您真的不走运,则您的代理可以是Microsoft NTLM代理。自由软件无法应付。唯一的解决方案是安装一个免费软件友好代理,该代理转发给讨厌的代理。http://cntlm.sourceforge.net/

找不到vcvarsall.bat

Python模块可以部分用C或C ++编写。Pip尝试从源代码进行编译。如果没有安装和配置C / C ++编译器,则会看到此错误消息。

错误:找不到vcvarsall.bat

您可以通过安装C ++编译器(例如MinGWVisual C ++)来解决此问题。微软实际上提供了一个专门用于Python的工具。或尝试使用Microsoft Visual C ++编译器Python 2.7

尽管通常更容易检查Christoph网站上的包裹。

Python 2.7.9+ and 3.4+

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 when using Python 3.4+ or Python 2.7.9+, simply execute e.g.:

py -3 -m ensurepip

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

And, alas for everyone using Python 2.7.8 or earlier (a sizable portion of the community). There’s no plan to ship Pip to you. Manual instructions follow.

Python 2 ≤ 2.7.8 and Python 3 ≤ 3.3

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:

python get-pip.py

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:

  1. Install setuptools
  2. Install pip

For me, 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 install httpie

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 and https_proxy. Most Python applications (and other free software) respect these. Example syntax:

http://proxy_url:port
http://username:password@proxy_url:port

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.

Error: Unable to find vcvarsall.bat

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.


回答 1

过时的 -使用分发,而不是此处所述的setuptools。-
过时的#2 -使用作为setuptools的分配已经过时了。

如前所述,pip不包含独立的安装程序,但是您可以使用其前身easy_install进行安装。

所以:

  1. 从此处下载最新的pip版本:http : //pypi.python.org/pypi/pip#downloads
  2. 解压缩
  3. 下载适用于Windows的最后一个简易安装程序:(http://pypi.python.org/pypi/setuptools底部下载.exe)。安装它。
  4. 将未压缩的pip文件夹内容复制到C:\Python2x\文件夹中(不要将整个文件夹复制到其中,仅复制内容),因为python命令在C:\Python2x文件夹外部不起作用,然后运行: python setup.py install
  5. 将您的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:

  1. Download the last pip version from here: http://pypi.python.org/pypi/pip#downloads
  2. Uncompress it
  3. Download the last easy installer for Windows: (download the .exe at the bottom of http://pypi.python.org/pypi/setuptools ). Install it.
  4. copy the uncompressed pip folder content into C:\Python2x\ folder (don’t copy the whole folder into it, just the content), because python command doesn’t work outside C:\Python2x folder and then run: python setup.py install
  5. Add your python C:\Python2x\Scripts to the path

You are done.

Now you can use pip install package to easily install packages as in Linux :)


回答 2

2014年更新:

1)如果您安装了Python 3.4或更高版本,则pip包含在Python中,并且应该已经在您的系统上运行。

2)如果您运行的版本低于Python 3.4,或者由于某些原因未在Python 3.4中安装pip,则您可能会使用pip的官方安装脚本get-pip.py。pip安装程序现在可以为您获取setuptools,并且可以在不考虑体系结构(32位或64位)的情况下运行。

这里详细说明了安装说明,其中包括:

要安装或升级pip,请安全下载get-pip.py

然后运行以下命令(可能需要管理员访问权限):

python get-pip.py

要升级现有的设置工具(或分发),请运行 pip install -U setuptools

为了后代,我将在下面保留两组旧说明。

旧答案:

对于Windows版本的64位版本-由于ez_setup,64位Windows + Python以前需要使用单独的安装方法,但是我已经在运行32位Python和64位Python的64位Windows上测试了新的分发方法,现在您可以对所有版本的Windows / Python 2.7X使用相同的方法:

使用分配的OLD方法2

  1. 下载分发 -我投入了我的想法C:\Python27\ScriptsScripts如果目录不存在,请随意创建。
  2. 打开命令提示符(在Windows上,如果不使用PowerShell,则应检出connemu2),然后将()更改为下载到的目录。cddistribute_setup.py
  3. 运行distribute_setup :(python distribute_setup.py如果您的python安装目录未添加到路径中,则此方法将不起作用- 请在此处获得帮助
  4. 将当前目录更改Scripts为Python安装目录(C:\Python27\Scripts),或者将该目录以及Python基本安装目录添加至您的%PATH%环境变量。
  5. 使用新安装的setuptools安装pip: easy_install pip

除非您easy_install.exe位于目录中(C:\ Python27 \ Scripts将是Python 2.7的默认设置),或者您将该目录添加到路径中,否则最后一步将不起作用。

使用ez_setup的OLD方法1

从setuptools页面

下载ez_setup.py并运行它;它将下载适当的.egg文件并为您安装。(当前,由于distutils安装程序的兼容性问题,提供的.exe安装程序不支持Windows的64位版本的Python。

之后,您可以继续:

  1. 添加c:\Python2x\Scripts到Windows路径(用已安装的实际版本号替换xin Python2x
  2. 打开一个新的(!)DOS提示符。从那里运行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:

To install or upgrade pip, securely download get-pip.py.

Then run the following (which may require administrator access):

python get-pip.py

To upgrade an existing setuptools (or distribute), run pip install -U setuptools

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:

  1. Download distribute – I threw mine in C:\Python27\Scripts (feel free to create a Scripts directory if it doesn’t exist.
  2. Open up a command prompt (on Windows you should check out conemu2 if you don’t use PowerShell) and change (cd) to the directory you’ve downloaded distribute_setup.py to.
  3. Run distribute_setup: python distribute_setup.py (This will not work if your python installation directory is not added to your path – go here for help)
  4. Change the current directory to the 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.
  5. Install pip using the newly installed setuptools: 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

Download ez_setup.py and run it; it will download the appropriate .egg file and install it for you. (Currently, the provided .exe installer does not support 64-bit versions of Python for Windows, due to a distutils installer compatibility issue.

After this, you may continue with:

  1. Add c:\Python2x\Scripts to the Windows path (replace the x in Python2x with the actual version number you have installed)
  2. Open a new (!) DOS prompt. From there run easy_install pip

回答 3

2016年更新:

这些答案已经过时,或者罗word且困难。

如果您拥有Python 3.4+或2.7.9+,它将默认安装在Windows上。否则,简而言之:

  1. 下载pip安装程序:https : //bootstrap.pypa.io/get-pip.py
  2. 如果偏执,请检查文件以确认它不是恶意的(必须b64解码)。
  3. 以Admin身份在下载文件夹中打开一个控制台,然后运行 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:

  1. Download the pip installer: https://bootstrap.pypa.io/get-pip.py
  2. If paranoid, inspect file to confirm it isn’t malicious (must b64 decode).
  3. Open a console in the download folder as Admin and run get-pip.py. Alternatively, right-click its icon in Explorer and choose the “run as Admin…”.

The new binaries pip.exe (and the deprecated easy_install.exe) will be found in the "%ProgramFiles%\PythonXX\Scripts" folder (or similar), which is often not in your PATH variable. I recommend adding it.


回答 4

2014年3月 发布的Python 3.4 pip附带了以下内容:
http : //docs.python.org/3.4/whatsnew/3.4.html
因此,自Python 3.4发布以来,最新的安装pip方法在Windows上只是安装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


回答 5

当我必须使用Windows时,我使用ActivePython,它将自动将所有内容添加到您的PATH中,并包括一个名为PyPM的软件包管理器,该软件包管理器提供了二进制软件包管理,从而使安装软件包变得更快,更简单。

pipeasy_install不是完全一样的东西,所以有一些事情可以打通pip,但不是easy_install ,反之亦然

我的建议是您获得ActivePython社区版,不要担心在Windows上为Python设置所有东西的麻烦。然后,您可以使用pypm

如果要使用pip,则必须检查PyPMActiveState安装程序中的选项。安装后,您只需要注销并再次登录,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 and easy_install aren’t exactly the same thing, so there are some things you can get through pip but not easy_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 the PyPM option in the ActiveState installer. After installation you only need to logoff and log on again, and pip will be available on the commandline, because it is contained in the ActiveState installer PyPM 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.


回答 6

最新的方法是使用Windows的软件包管理器Chocolatey

安装完成后,您所要做的就是打开命令提示符并运行下面的以下三个命令,这将安装Python 2.7,easy_install和pip。它会自动检测您是在x64还是x86 Windows上。

cinst python
cinst easy.install
cinst pip

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.

cinst python
cinst easy.install
cinst pip

All of the other Python packages on the Chocolatey Gallery can be found here.


回答 7

2015年3月更新

Python 2.7.9和更高版本(在Python 2系列上)以及Python 3.4和更高版本默认情况下都包含pip,因此您可能已经拥有pip。

如果不这样做,请在提示符下运行以下一行命令(可能需要管理员访问权限):

python -c "exec('try: from urllib2 import urlopen \nexcept: from urllib.request import urlopen');f=urlopen('https://bootstrap.pypa.io/get-pip.py').read();exec(f)"

它将安装pip。如果尚未安装Setuptoolsget-pip.py也将为您安装它。

如评论中所述,以上命令将从GitHub上的Pip源代码存储库下载代码,并在您的环境中动态运行它。因此请注意,这是下载,检查和运行步骤的快捷方式,所有这些操作都使用Python本身通过一个命令完成。如果您信任Pip,请毫无疑问地继续。

确保Windows环境变量PATH包含Python的文件夹(对于Python 2.7.x,默认安装:C:\Python27C:\Python27\Scripts,对于Python 3.3x:C:\Python33C:\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):

python -c "exec('try: from urllib2 import urlopen \nexcept: from urllib.request import urlopen');f=urlopen('https://bootstrap.pypa.io/get-pip.py').read();exec(f)"

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 and C:\Python27\Scripts, for Python 3.3x: C:\Python33 and C:\Python33\Scripts, and so on).


回答 8

安装人员

我内置的Windows安装两种分发PIP这里(其目标是使用pip,而无需任何引导用easy_install或保存和运行Python脚本):

在Windows上,只需先下载并安装distribute,然后pip从上面的链接下载即可。distribute上面的链接确实包含存根.exe安装程序,并且当前仅32位。我尚未在64位Windows上测试过效果。

在Windows上构建

将其重做为新版本的过程并不困难,我将其包含在此处以供参考。

建造 distribute

为了获得存根.exe文件,您需要具有Visual C ++编译器(显然也可以与MinGW一起编译)

hg clone https://bitbucket.org/tarek/distribute
cd distribute
hg checkout 0.6.27
rem optionally, comment out tag_build and tag_svn_revision in setup.cfg
msvc-build-launcher.cmd
python setup.py bdist_win32
cd ..
echo build is in distribute\dist

建造 pip

git clone https://github.com/pypa/pip.git
cd pip
git checkout 1.1
python setup.py bdist_win32
cd ..
echo build is in pip\dist

Installers

I’ve built Windows installers for both distribute and pip here (the goal being to use pip without having to either bootstrap with easy_install or save and run Python scripts):

On Windows, simply download and install first distribute, then pip from the above links. The distribute 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)

hg clone https://bitbucket.org/tarek/distribute
cd distribute
hg checkout 0.6.27
rem optionally, comment out tag_build and tag_svn_revision in setup.cfg
msvc-build-launcher.cmd
python setup.py bdist_win32
cd ..
echo build is in distribute\dist

Building pip

git clone https://github.com/pypa/pip.git
cd pip
git checkout 1.1
python setup.py bdist_win32
cd ..
echo build is in pip\dist

回答 9

以下内容适用于Python 2.7。保存此脚本并启动它:

https:

//raw.github.com/pypa/pip/master/contrib/get-pip.py安装了Pip,然后将路径添加到您的环境:

C:\Python27\Scripts

最后

pip install virtualenv

另外,您还需要Microsoft Visual C ++ 2008 Express才能获得良好的编译器,并在安装软件包时避免出现此类消息:

error: Unable to find vcvarsall.bat

如果您使用的是Windows 7的64位版本,则可能会在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 :

C:\Python27\Scripts

Finally

pip install virtualenv

Also you need Microsoft Visual C++ 2008 Express to get the good compiler and avoid these kind of messages when installing packages:

error: Unable to find vcvarsall.bat

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


回答 10

对于最新的Python下载-我在Windows上安装了python 3.6。您不必怀疑所需的一切都在那里,请屏息,我将向您展示如何做到这一点。

  1. 确保为我安装python的位置在以下目录中

现在,如果您在Windows上,让我们将python和pip添加到环境变量路径设置中,以便在任何地方键入pip或python都可以从安装它们的地方调用python aor pip。

因此,在屏幕上方“ SCRIPTS ” 下的文件夹下找到PIP,让我们在环境变量路径中添加Python和PIP。

快完成了,让我们用CMD进行测试以使用pip安装goole软件包。

pip install google

再见!

For latest Python Download – I have python 3.6 on windows. You don’t have to wonder everything you need is there , take a breath i will show you how to do it.

  1. make sure where you install python for me its was in the following directory

Now , lets add python and pip into environment variable path settings if you are on windows, so that typing pip or python anywhere call python aor pip from where they are installed.

So, PIP is found under the folder in above screen “SCRIPTS” Lets add Python and PIP in environment variable path.

Almost Done , Let test with CMD to install goole package using pip.

pip install google

BYE BYE!


回答 11

要在Python 2.x上全局安装pip ,如Adrián所述,easy_install似乎是最好的解决方案。

但是pip 的安装说明建议使用virtualenv,因为每个virtualenv都会自动安装pip。这不需要root用户访问权限或修改系统Python安装。

尽管安装virtualenv仍然需要easy_install。

2018更新:

Python 3.3+现在包含venv模块,可轻松创建虚拟环境,如下所示:

python3 -m venv /path/to/new/virtual/environment

请参阅有关在创建后激活环境的不同平台方法的文档,但通常为以下之一:

$ source <venv>/bin/activate 

C:\> <venv>\Scripts\activate.bat

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:

python3 -m venv /path/to/new/virtual/environment

See documentation for different platform methods of activating the environment after creation, but typically one of:

$ source <venv>/bin/activate 

C:\> <venv>\Scripts\activate.bat

回答 12

要使用pip,并不一定需要直接在系统中安装pip。您可以通过使用它virtualenv。您可以按照以下步骤操作:

我们通常需要为一个特定项目安装Python软件包。因此,现在创建一个项目文件夹,比方说myproject。

  • 从的解压缩文件夹中复制virtualenv.py文件virtualenv,并将其粘贴到myproject文件夹中

现在创建一个虚拟环境,在myproject文件夹中,如下所示说myvirtualenv

python virtualenv.py myvirtualenv

它会向您显示:

New python executable in myvirtualenv\Scripts\python.exe
Installing setuptools....................................done.
Installing pip.........................done.

现在,您的虚拟环境myvirtualenv已在项目文件夹中创建。您可能会注意到,pip现在已安装在您的虚拟环境中。您需要做的就是使用以下命令激活虚拟环境。

myvirtualenv\Scripts\activate

您将在命令提示符下看到以下内容:

(myvirtualenv) PATH\TO\YOUR\PROJECT\FOLDER>pip install package_name

现在,您可以开始使用pip,但是请确保已激活虚拟环境,方法是查看提示左侧的内容。

这是在虚拟环境中安装pip的最简单方法之一,但是您需要随身携带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.

  • Copy the virtualenv.py file from the decompressed folder of virtualenv, and paste inside the myproject folder

Now create a virtual environment, let’s say myvirtualenv as follows, inside the myproject folder:

python virtualenv.py myvirtualenv

It will show you:

New python executable in myvirtualenv\Scripts\python.exe
Installing setuptools....................................done.
Installing pip.........................done.

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.

myvirtualenv\Scripts\activate

You will see the following at the command prompt:

(myvirtualenv) PATH\TO\YOUR\PROJECT\FOLDER>pip install package_name

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.


回答 13

我只是想为那些无法从Windows 64位安装setuptools的用户添加一个解决方案。在python.org上的此错误中讨论了该问题,截至本评论发布之日仍未解决。提到了一个简单的解决方法,它可以完美地工作。一次注册表更改对我来说很成功。

链接:http//bugs.python.org/issue6792#

适用于我的解决方案…:

为2.6+版本的Python添加此注册表设置:

 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.6\InstallPath]
 @="C:\\Python26\\"

这很可能是您在Python 2.6+中已经拥有的注册表设置:

 [HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\InstallPath]
 @="C:\\Python26\\"

显然,您将需要用正在运行的Python版本替换2.6版本。

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:

 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.6\InstallPath]
 @="C:\\Python26\\"

This is most likely the registry setting you will already have for Python 2.6+:

 [HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\InstallPath]
 @="C:\\Python26\\"

Clearly, you will need to replace the 2.6 version with whatever version of Python you are running.


回答 14

更新于2016年: Pip应该已经包含在中Python 2.7.9+ or 3.4+,但是如果由于某种原因它不存在,则可以使用以下一种格式。

PS:

  1. 在大多数情况下,这已经可以满足要求,但是,如果有必要,请确保环境变量PATH包含Python的文件夹(例如,Python 2.7.x在Windows默认安装:C:\Python27 and C:\Python27\Scripts,for Python 3.3xC:\Python33 and C:\Python33\Scripts等)

  2. 我遇到同样的问题,然后在这里的官方网站上找到了这种最简单的方法(一行代码!): http //www.pip-installer.org/en/latest/installing.html

不敢相信那里有这么长的答案(也许已经过时了?)。对他们表示感谢,但请对这个简短的答案进行投票,以帮助更多的新手!

Updated at 2016 : Pip should already be included in Python 2.7.9+ or 3.4+, but if for whatever reason it is not there, you can use the following one-liner.

PS:

  1. 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, for Python 3.3x: C:\Python33 and C:\Python33\Scripts, etc)

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


回答 15

到目前为止,我发现的最好方法就是两行代码:

curl http://python-distribute.org/distribute_setup.py | python
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

它已在Windows 8上使用PowerShell,Cmd和Git Bash(MinGW)进行了测试。

您可能想要将路径添加到您的环境。就像C:\Python33\Scripts

The best way I found so far, is just two lines of code:

curl http://python-distribute.org/distribute_setup.py | python
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

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.


回答 16

在这里,如何通过简单的方法安装pip。

  1. 这些内容复制并粘贴为get-pip.py文件
  2. get-pip.py复制并粘贴到python文件夹中。C:\Python27
  3. 双击获取get-pip.py文件,它将pip安装到您的计算机上。
  4. 现在您必须为C:\Python27\Scripts环境变量添加路径,因为它包含pip.exe文件。
  5. 现在您可以使用点子了。打开cmd并键入为
    pip install package_name

Here how to install pip with easy way.

  1. copy and paste these content in a file as get-pip.py
  2. copy and paste get-pip.py into python folder.C:\Python27
  3. Double click to get-pip.py file.it will install pip to your computer.
  4. Now you have to add C:\Python27\Scripts path to your enviroment variable.Because it includes pip.exe file.
  5. Now you are ready to use pip. Open cmd and type as
    pip install package_name

回答 17

PythonXY带有pip包括,除其他

PythonXY comes with pip included, among others.


回答 18

我在Windows上使用来自continuum.io 的跨平台Anaconda软件包管理器,它是可靠的。它具有虚拟环境管理功能以及具有常用功能(例如conda,pip)的功能齐全的外壳。

> conda install <package>               # access distributed binaries

> pip install <package>                 # access PyPI packages 

conda还附带了具有非Python依赖项(例如pandasnumpy等)的库的二进制文件。这在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 install <package>               # access distributed binaries

> pip install <package>                 # access PyPI packages 

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.


回答 19

按照此处的说明进行安装时,我遇到了一些问题。我认为以相同的方式在每个Windows环境中安装非常棘手。就我而言,出于同一目的,我需要在同一台计算机上使用Python 2.6、2.7和3.3,这就是为什么我认为还有更多问题的原因。但是以下说明对我来说非常有效,因此可能要根据您的环境尝试使用此说明:

http://docs.python-guide.org/zh-CN/latest/starting/install/win/

另外,由于不同的环境,我发现使用虚拟环境非常有用,我的网站使用不同的库,最好将它们封装到一个文件夹中,查看说明,如果已安装PIP,则只需安装VirtualEnv:

pip install virtualenv

将所有文件运行到该文件夹​​中

virtualenv venv

几秒钟后,您将在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:

pip install virtualenv

Into the folder you have all your files run

virtualenv venv

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.


回答 20

  1. 下载脚本:https : //raw.github.com/pypa/pip/master/contrib/get-pip.py
  2. 将其保存在驱动器上,例如C:\ pip-script \ get-pip.py
  3. 从命令提示符导航到该路径,然后运行“ python get-pip.py”

指南链接:http : //www.pip-installer.org/en/latest/installing.html#install-pip

注意:请确保还将这样的脚本路径(C:\ Python27 \ Scripts)添加到int%PATH%环境变量中。

  1. Download script: https://raw.github.com/pypa/pip/master/contrib/get-pip.py
  2. Save it on drive somewhere like C:\pip-script\get-pip.py
  3. Navigate to that path from command prompt and run ” python get-pip.py “

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.


回答 21

很简单:

Step 1: wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
Step 2: wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
Step 2: python ez_setup.py
Step 3: python get-pip.py

(确保您的Python和Python脚本目录(例如C:\Python27C:\Python27\Scripts)在PATH中。)

It’s very simple:

Step 1: wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
Step 2: wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
Step 2: python ez_setup.py
Step 3: python get-pip.py

(Make sure your Python and Python script directory (for example, C:\Python27 and C:\Python27\Scripts) are in the PATH.)


回答 22

从2014年2月4日开始工作:):

如果您按照@Colonel Panic的建议尝试通过Windows安装程序文件从http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip安装pip ,则可能已成功安装了pip软件包管理器,但是您可能无法使用pip安装任何软件包。如果您查看pip.log文件,您可能还会遇到与尝试安装Beautiful Soup 4时遇到的SSL错误相同的错误:

Downloading/unpacking beautifulsoup4
  Getting page https://pypi.python.org/simple/beautifulsoup4/
  Could not fetch URL https://pypi.python.org/simple/beautifulsoup4/: **connection error: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed**
  Will skip URL https://pypi.python.org/simple/beautifulsoup4/ when looking for download links for beautifulsoup4

问题是OpenSSL的旧版本与pip 1.3.1及更高版本不兼容。目前,最简单的解决方法是安装不需要SSL的 pip 1.2.1

在Windows上安装Pip:

  1. https://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz下载pip 1.2.1
  2. 提取pip-1.2.1.tar.gz文件
  3. 将目录更改为提取的文件夹: cd <path to extracted folder>/pip-1.2.1
  4. python setup.py install
  5. 现在确保C:\Python27\Scripts位于PATH中,因为pip安装在C:\Python27\Scripts目录中,这与C:\Python27\Lib\site-packages通常安装Python软件包的位置不同

现在尝试使用pip安装任何软件包。

例如,要requests使用pip 安装软件包,请从cmd运行此命令:

pip install requests

哇!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:

Downloading/unpacking beautifulsoup4
  Getting page https://pypi.python.org/simple/beautifulsoup4/
  Could not fetch URL https://pypi.python.org/simple/beautifulsoup4/: **connection error: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed**
  Will skip URL https://pypi.python.org/simple/beautifulsoup4/ when looking for download links for beautifulsoup4

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:

  1. Download pip 1.2.1 from https://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz
  2. Extract the pip-1.2.1.tar.gz file
  3. Change directory to the extracted folder: cd <path to extracted folder>/pip-1.2.1
  4. Run python setup.py install
  5. Now make sure C:\Python27\Scripts is in PATH because pip is installed in the C:\Python27\Scripts directory unlike C:\Python27\Lib\site-packages where Python packages are normally installed

Now try to install any package using pip.

For example, to install the requests package using pip, run this from cmd:

pip install requests

Whola! requests will be successfully installed and you will get a success message.


回答 23

如果您使用的是从python.org下载的Python 2> = 2.7.9或Python 3> = 3.4二进制文件,则已经安装了pip,但是您需要升级pip。

在Windows上可以轻松完成升级

转到Python命令行并在Python命令下运行

python -m pip install -U pip

使用get-pip.py安装

get-pip.py下载到同一文件夹或您选择的任何其他文件夹中。我假设您将从python.exe文件将其下载到同一文件夹中,然后运行此命令

python get-pip.py

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 upgrade can be done easily

Go to Python command line and run below Python command

python -m pip install -U pip

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 you have python.exe file and run this command

python get-pip.py

Pip’s installation guide is pretty clean and simple.

Using this you should be able to get started with Pip in under two minutes.


回答 24

如果您甚至对pip版本有其他问题,可以尝试一下

pip install --trusted-host pypi.python.org --upgrade pip

if you even have other problems with pip version you can try this

pip install --trusted-host pypi.python.org --upgrade pip

回答 25

简单的CMD方法

使用CURL下载get-pip.py

curl --http1.1 https://bootstrap.pypa.io/get-pip.py --output get-pip.py

执行下载的python文件

python get-pip.py

然后将C:\Python37\Scripts路径添加到您的环境变量。假设Python37您的C盘中有一个文件夹,该文件夹的名称可能会因安装的python版本而异

现在,您可以通过运行来安装python软件包

pip install awesome_package_name

Simple CMD way

Use CURL to download get-pip.py

curl --http1.1 https://bootstrap.pypa.io/get-pip.py --output get-pip.py

Execute downloaded python file

python get-pip.py

Then add C:\Python37\Scripts path to your environment variable. Assumes that there is a Python37 folder in your C drive, that folder name may varied according to the installed python version

Now you can install python packages by running

pip install awesome_package_name

回答 26

Python2和安装PipPython3

  1. get-pip.py下载到计算机上的文件夹。
  2. 打开命令提示符,然后导航到包含的文件夹get-pip.py
  3. 运行以下命令:python get-pip.pypython3 get-pip.pypython3.6 get-pip.py,取决于哪个版本的python要安装pip
  4. 点现在应该安装了!

旧答案(仍然有效)

你有没有尝试过 ?

python -m ensurepip

这可能是在任何系统上安装pip的最简单方法。

Installing Pip for Python2 and Python3

  1. Download get-pip.py to a folder on your computer.
  2. Open a command prompt and navigate to the folder containing get-pip.py.
  3. Run the following command:python get-pip.py, python3 get-pip.py or python3.6 get-pip.py, depending on which version of python you want to install pip
  4. Pip should be now installed!

Old answer (still valid)

Have you tried ?

python -m ensurepip

it’s probably the easiest to install pip on any system.


回答 27

只需从此处https://pypi.python.org/pypi/setuptools#windows-simplified下载setuptools-15.2.zip(md5),然后运行ez_setup.py。

Just download setuptools-15.2.zip (md5), from here https://pypi.python.org/pypi/setuptools#windows-simplified , and run ez_setup.py.


回答 28

或者,您可以获得pip-Win,它是pip的多合一安装程序,并且virtualenv在Windows及其GUI上。

  • 从一个Python解释器(即版本)切换到另一个(包括py和pypy)
  • 查看所有已安装的软件包,以及它们是否为最新
  • 安装或升级软件包,或升级pip本身
  • 创建和删除虚拟环境,并在它们之间切换
  • 使用选定的解释器运行IDLE或其他Python脚本

Alternatively, you can get pip-Win which is an all-in-one installer for pip and virtualenv on Windows and its GUI.

  • Switch from one Python interpreter (i.e. version) to another (including py and pypy)
  • See all installed packages, and whether they are up-to-date
  • Install or upgrade a package, or upgrade pip itself
  • Create and delete virtual environments, and switch between them
  • Run the IDLE or another Python script, with the selected interpreter

回答 29

现在,它与Python捆绑在一起。您不需要安装它。

pip -V

这样可以检查是否已安装pip。在极少数情况下,如果未安装,请下载get-pip.py文件并使用python作为

python get-pip.py

Now, it is bundled with Python. You don’t need to install it.

pip -V

This is how you can check whether pip is installed or not. In rare case, if it is not installed, download get-pip.py file and run it with python as

python get-pip.py