我想安装pip。它应该支持Python 3,但它需要setuptools,这只适用于Python 2。
如何在python3中安装pip ?
我想安装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
其他回答
对于Ubuntu 12.04或更高版本,
sudo apt-get install python3-pip
不能工作。相反,使用:
sudo apt-get install python3-setuptools ca-certificates
sudo easy_install3 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
如果您的Linux发行版已经安装了Python,那么您应该能够使用系统的包管理器安装PIP。这是可取的,因为系统安装的Python版本不能很好地使用在Windows和Mac上使用的get-pip.py脚本。
高级软件包工具(Python 2.x)
sudo apt-get install python-pip
高级软件包工具(Python 3.x)
sudo apt-get install python3-pip
包管理器(Python 2.x)
sudo pacman -S python2-pip
包管理器(Python 3.x)
sudo pacman -S python-pip
Yum Package Manager (Python 2.x)
sudo yum upgrade python-setuptools
sudo yum install python-pip python-wheel
Yum Package Manager (Python 3.x)
sudo yum install python3 python3-wheel
Dandified Yum (Python 2.x)
sudo dnf upgrade python-setuptools
sudo dnf install python-pip python-wheel
Dandified Yum (Python 3.x)
sudo dnf install python3 python3-wheel
Zypper包管理器(Python 2.x)
sudo zypper install python-pip python-setuptools python-wheel
Zypper包管理器(Python 3.x)
sudo zypper install python3-pip python3-setuptools python3-wheel
python3 -m ensurepip
我不确定这是什么时候引入的,但是当它还不存在的时候,我为它安装了pip3。
更新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