我想安装pip。它应该支持Python 3,但它需要setuptools,这只适用于Python 2。

如何在python3中安装pip ?


当前回答

假设你在一个高度受限的计算机环境中(比如我自己),没有root权限或安装包的能力……

在这篇文章之前,我从来没有设置过Python+virtualenv的新/独立/原始/非根实例。为了做到这一点,我在谷歌上搜索了很多。

Decide if you are using python (python2) or python3 and set your PATH correctly. (I am strictly a python3 user.) All commands below can substitute python3 for python if you are python2 user. wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-x.y.z.tar.gz tar -xzvf virtualenv-x.y.z.tar.gz python3 virtualenv-x.y.z/virtualenv.py --python $(which python3) /path/to/new/virtualenv source /path/to/new/virtualenv/bin/activate Assumes you are using a Bourne-compatible shell, e.g., bash Brilliantly, this virtualenv package includes a standalone version of pip and setuptools that are auto-magically installed into each new virtualenv. This solves the chicken and egg problem. You may want to create an alias (or update your ~/.bashrc, etc.) for this final command to activate the python virtualenv during each login. It can be a pain to remember all these paths and commands. Check your version of python now: which python3 should give: /path/to/new/virtualenv/bin/python3 Check pip is also available in the virtualenv via which pip... should give: /path/to/new/virtualenv/bin/pip

然后……皮皮,皮皮,皮皮!

给python新手的最后一个提示:在开始时,您认为不需要virtualenv,但以后会很高兴拥有它。帮助开源/共享包的“假设”安装/升级场景。

裁判:https://virtualenv.pypa.io/en/latest/installation.html

其他回答

更新2015-01-20:

根据https://pip.pypa.io/en/latest/installing.html,目前的方式是:

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

我认为这适用于任何版本


最初的回答:

wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip

Python 3.4新增功能 ... PIP应始终可用 ... 缺省情况下,命令pipX和pipX。Y将被安装在所有平台上(其中X.Y代表Python安装的版本),以及pip Python包及其依赖项。

https://docs.python.org/3/whatsnew/3.4.html#whatsnew-pep-453

所以如果你安装了python 3.4,你可以:sudo pip3 install XXX

python3 -m ensurepip

我不确定这是什么时候引入的,但是当它还不存在的时候,我为它安装了pip3。

请按照以下步骤安装python 3和pip:

步骤1:从这里下载安装Python

步骤2:需要下载get-pip.py

步骤3:下载get-pip.py后,打开命令提示符并进入保存get-pip.py文件的目录。

第四步:在cmd下输入命令python get-pip.py。

步骤5:Pip installed successfully, Verify Pip installation by type command in cmd Pip——version

我可以通过运行sudo apt-get install python3-pip在Ubuntu上为python3安装pip。