Python Package Installer - easy_install & pip
Introduce Python Package Installation Tools.
PyPA » Python Packaging User Guide » Guides » Tool recommendations
- Installation Tool Recommendations
- Use pip to install Python packages from PyPI.
- Use virtualenv, or venv to isolate application specific dependencies from a shared Python installation.
- Packaging Tool Recommendations
- Use setuptools to define projects and create Source Distributions.
- Use the
bdist_wheelsetuptools extension available from the wheel project to create wheels. This is especially beneficial, if your project contains binary extensions.
Python有两个著名的包管理工具 easy_install.py 和 pip。
在 Python2.7 的安装包中,easy_install.py 是默认安装的,而 pip 需要我们手动安装。
在 python 2.7.9+ 及 python 3.4+ 的安装包中,默认已经自带 pip 包管理器。
easy_install#
EasyInstall (easy_install) gives you a quick and painless way to install packages remotely by connecting to the cheeseshop or even other websites via HTTP. It is somewhat analogous to the CPAN and PEAR tools for Perl and PHP, respectively.
setuptools 36.6.0 documentation » Easy Install
Easy Install is a python module (easy_install) bundled with setuptools that lets you automatically download, build, install, and manage Python packages.
在 macOS/raspbian 终端输入 easy_install 再按下 tab 可查看所有版本的 easy_install;
- 输入
easy_install --version命令可查看 Python 2.7 对应的 easy_install 的版本号; - 输入
easy_install-3.6 --version(easy_install3 --version)可查看 Python 3.* 对应的 easy_install 的版本号。
faner@FAN-MB0:~|⇒ easy_install
easy_install easy_install-2.6 easy_install-2.7 easy_install-3.6
faner@FAN-MB0:~|⇒ easy_install --version
setuptools 18.5 from /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (Python 2.7)
faner@FAN-MB0:~|⇒ easy_install-3.6 --version
setuptools 36.5.0 from /usr/local/lib/python3.6/site-packages (Python 3.6)
pi@raspberrypi:~ $ easy_install
easy_install easy_install3
pi@raspberrypi:~ $ easy_install --version
setuptools 33.1.1 from /usr/lib/python2.7/dist-packages (Python 2.7)
pi@raspberrypi:~ $ easy_install3 --version
setuptools 33.1.1 from /usr/lib/python3/dist-packages (Python 3.5)
pip#
The PyPA recommended tool for installing Python packages.
pip works on Unix/Linux, macOS, and Windows.
Pip is a modern, general purpose installation tool for python packages. Most often it is useful to install it in your system python.
pip 是一个以 Python 计算机程序语言写成的软件包管理系统,他可以安装和管理软件包。
另外,不少的软件包也可以在 PyPI 中找到。
Installation#
Installation: To install pip, securely download get-pip.py
Then run the following:
Installing pip/setuptools/wheel with Linux Package Managers
怎么在windows下安装pip?
windows下面安装Python和pip终极教程
pip2 & pip3#
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.
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.
输入 pip 默认运行 pip 2,输入 pip3 则指定运行版本3的 pip。
# macOS
faner@FAN-MB0:~|⇒ pip3 -V
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
faner@FAN-MB0:~|⇒ which pip3
/usr/local/bin/pip3
# raspbian
pi@raspberrypi:~ $ pip -V
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
pi@raspberrypi:~ $ which pip
/usr/bin/pip
pi@raspberrypi:~ $ whereis pip
pip: /usr/bin/pip /etc/pip.conf /usr/share/man/man1/pip.1.gz
pi@raspberrypi:~ $ pip3 -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
pi@raspberrypi:~ $ which pip3
/usr/bin/pip3
pi@raspberrypi:~ $ whereis pip3
pip3: /usr/bin/pip3 /usr/share/man/man1/pip3.1.gz
pip over easy_install#
Installing Python Modules: pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers.
reason#
pip vs easy_install
Why use pip over easy_install?
Pip Compared To easy_install
- pip provides an
uninstallcommand - if an installation fails in the middle, pip will leave you in a clean state.
- Requirements files allow you to create a snapshot of all packages that have been installed through
pip.
@img 
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.
@img 
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.