How to install pip with Python 3?
I want to install pip. It should support Python 3, but it requires setuptools, which is available only for Python 2.
How can I install pip with Python 3?
edit: Manual installation and use of setuptools
is not the standard process anymore.
If you're running Python 2.7.9+ or Python 3.4+
Congrats, you should already have pip
installed. If you do not, read onward.
If you're running a Unix-like System
You can usually install the package for pip
through your package manager if your version of Python is older than 2.7.9 or 3.4, or if your system did not include it for whatever reason.
Instructions for some of the more common distros follow.
Installing on Debian (Wheezy and newer) and Ubuntu (Trusty Tahr and newer) for Python 2.x
Run the following command from a terminal:
sudo apt-get install python-pip
Installing on Debian (Wheezy and newer) and Ubuntu (Trusty Tahr and newer) for Python 3.x
Run the following command from a terminal:
sudo apt-get install python3-pip
Installing pip
on CentOS 7 for Python 2.x
On CentOS 7, you have to install setup tools first, and then use that to install pip
, as there is no direct package for it.
sudo yum install python-setuptools
sudo easy_install pip
Installing pip
on CentOS 7 for Python 3.x
Assuming you installed Python 3.4 from EPEL, you can install Python 3's setup tools and use it to install pip
.
# First command requires you to have enabled EPEL for CentOS7
sudo yum install python34-setuptools
sudo easy_install pip
If your Unix/Linux distro doesn't have it in package repos
Install using the manual way detailed below.
The manual way
If you want to do it the manual way, the now-recommended method is to install using the get-pip.py
script from pip
's installation instructions.
Install pip
To install pip, securely download get-pip.py
Then run the following (which may require administrator access):
python get-pip.py
If setuptools
is not already installed, get-pip.py
will install setuptools for you.
我可以通过运行sudo apt-get install python3-pip
在Ubuntu上安装python 3 sudo apt-get install python3-pip
。
Python 3.4+ and Python 2.7.9+
Good news! Python 3.4 (released March 2014) ships 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 by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Nodejs, Haskell, Perl, Go--almost every other contemporary language with a majority open-source community. Thank you Python.
Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this at Does Python have a package/module management system?
Alas for everyone using an earlier Python. Manual instructions follow.
Python ≤ 2.7.8 and Python ≤ 3.3
Follow my detailed instructions at https://stackoverflow.com/a/12476379/284795 . Essentially
Official instructions
Per https://pip.pypa.io/en/stable/installing.html
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 http://technet.microsoft.com/en-us/library/cc947813(v=ws.10).aspx
For me, this installed Pip at C:Python27Scriptspip.exe
. Find pip.exe
on your computer, then add its folder (eg. C:Python27Scripts
) 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)!
链接地址: http://www.djcxy.com/p/26320.html上一篇: 更改序列H2DB的数据类型
下一篇: 如何用Python 3安装pip?