Home  >  Article  >  Backend Development  >  Detailed introduction to Python’s package management tools

Detailed introduction to Python’s package management tools

高洛峰
高洛峰Original
2017-03-17 16:06:481255browse

When I first started learning Python, I was reading documents and other people’s blogs to introduce installation packages. Some use easy_install, setuptools, and some use pip and distribute. So these tools What does it have to do with it? You will understand if you look at the picture below

Detailed introduction to Python’s package management tools

You can see that distribute is the replacement of setuptools and pip is the replacement of easy_install.

For information about these package tools, please refer to http://guide.python-distribute.org/installation.html#installing-pip

The following is a brief introduction:

Distribute It is an enhancement to the disutils module of the standard library. We know that disutils is mainly used to package and distribute packages more easily, especially packages that have dependencies on other packages.

Distribute was created because the Setuptools package is no longer maintained.

Install Distribute

You can install Distribute through the distribute_setup.py script, or you can install it through easy_install, pip, and source files, but using distribute_setup.py to install is the simplest and most popular Method

$ curl -0 http://python-distribute.org/distribute_setup.py

$ sudo python distribute_setup.py

Pip is a tool for installing python packages. It provides the functions of installing packages, listing installed packages, upgrading packages and uninstalling packages.

Pip is a replacement for easy_install and provides the same function of finding packages as easy_install. Therefore, packages that can be installed using easy_install can also be installed using pip.

Installing Pip

Pip can be installed through the source code package, easy_install or script.

The various installation methods are introduced below:

Source code method:

$ wget http://pypi.python.org/packages/ source/p/pip/pip-0.7.2.tar.gz (replace with the latest package)

$ tar xzf pip-0.7.2.tar.gz

$ cd pip- 0.7.2

$ python setup.py install

easy_install:

$ easy_install pip

get_pip.py script:

$ curl -0 https://raw.github.com/pypa/pip/master/contrib/get-pip.py

$ sudo python get-pip .py

OK, let’s take a look at how to use Pip

Install package

$ pip install Markdown

List installed packages

$ pip freeze

Install a specific version of a package

By using ==, >=, < ;=, >,

$ pip install 'Markdown

$ pip install 'Markdown>2.0,

Upgrade package

To upgrade the package to the latest version, you can use -U or --upgrade

$ pip install -U Markdown

Uninstall package

$ pip uninstall Markdown

Query package

pip search "Markdown"

PS -- py file path after package installation: /usr/local/lib/python2.7/dist-packages


The above is the detailed content of Detailed introduction to Python’s package management tools. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn