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

如何在python3中安装pip ?


当前回答

对于Ubuntu 12.04或更高版本,

sudo apt-get install python3-pip

不能工作。相反,使用:

sudo apt-get install python3-setuptools ca-certificates
sudo easy_install3 pip

其他回答

对于Ubuntu 12.04或更高版本,

sudo apt-get install python3-pip

不能工作。相反,使用:

sudo apt-get install python3-setuptools ca-certificates
sudo easy_install3 pip

要安装pip,请安全地下载get-pip.py。

然后执行如下命令:

python get-pip.py

如果您使用的Python安装由您的 操作系统或其他包管理器。py没有 与这些工具进行协调,可能会使您的系统处于一个 不一致的状态。

参考: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

在安装Python时,pip会一起安装。你可以使用 Sudo PIP安装(模块) 或 Python3 -m PIP安装(模块)。

下面是我在ubuntu 12.04中解决这个问题的方法:

sudo apt-get install build-essential libncursesw5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev

然后从源代码安装python3:

wget https://www.python.org/ftp/python/3.4.0/Python-3.4.0.tar.xz
tar xvf Python-3.4.0.tar.xz
cd Python-3.4.0
./configure
make
make test
sudo make install

当您完成所有这些程序的安装后,pip3将自动安装。