General Python Package Installation method
1. Download package
2. Python setup.py build #可能不需要
3. Python setup.py Install
Python installs the command of the package some easy_install, Setuptools, also have Pip,distribute
Distribute is the replacement of Setuptools, Pip is the replacement of Easy_install.
Setuptools
Setuptools manages Python's third-party package, installs the package under Site-package, and installs a package suffix that is typically. Egg, which is actually in the zip format. The default download package from Http://pypi.python.org/pypi is able to resolve the Python package dependencies.
Setuptools is an enhanced version of Python distutils, making it easier for developers to build and publish Python packages, especially when packages are dependent on other packages. Packages built and published with Setuptools are similar to packages released with Distutils
Distribute is an enhancement to the standard library Disutils module, Disutils is primarily used to more easily package and distribute packages, especially those that have dependencies on other packages.
Distribute was created because the Setuptools package is no longer maintained.
Pip is a replacement for Easy_install, which provides the same functionality for finding packages as Easy_install, so packages that can be installed using Easy_install can also be installed using PIP.
Introduction to Easy_install and PIP:
Easy_install and Pip are all used to download a common repository for installing Python PyPI
The relevant resource bundle, PIP is an improved version of Easy_install, providing a better cue letter
The package and other functions. The old version of Python is only Easy_install,
No PIP.
Easy_install Packaging and publishing Python packages
# Easy_install Package # Normal Installation
# Easy_install/home/yeolar/pkg/package.egg # Install from a local or network file system
# easy_install http://trac-hacks.org/svn/iniadminplugin/0.11/# Install from the specified download path
# easy_install http://pypi.python.org/simple/PACKAGE/PACKAGE-0.1.2.4.tar.gz # Install from URL source package, The condition is that the setup.py file must be included in the root directory in the package-0.1.2.4.tar.gz package
# easy_install-f Http://pypi.python.org/simple/PACKAGE # Search for packages from the Web and install them automatically
# easy_install package==0.1.2.1 # Specifies the version of the package, if the specified version is higher than the now installed version is the upgrade
# Easy_install-u Package # Upgrade to the latest version, without specifying the version will be upgraded to the latest version
# easy_install-u package==0.1.2.2 # Upgrade to the specified version
# EASY_INSTALL-M Package # Uninstall packages, uninstall and delete legacy files manually
PIP is a package management
Usage of Easy_install:
Install a Package
Easy_install Package Name
Easy_install "Package name = = Version number of package"
Upgrade a Package
Easy_install-u "Package name >= Package version number"
Usage of PIP
Install a Package
Pip Install package name
Pip Install package name = = The version number of the package (by using = =, >=, <=,;, < to specify a version number.) )
Pip install ' markdown<2.0 '
Upgrade a package (if no version number is provided, upgrade to the latest version)
Pip Install--upgrade package name >= Package version number
Delete a Package
Pip Uninstall Package name
List the installed packages
$ pip Freeze
Query Package
PIP Search Package Name
Virtualenv
Virtualenv is a python environment configuration and switching tool that can be used to configure multiple Python runtime environments to isolate the Python environment in the system, known as a sandbox. The benefits of sandboxing include:
Resolve version dependencies between libraries, such as different applications on the same system that depend on different versions of the same library.
Resolve permissions restrictions, such as you do not have root privileges.
Try new tools without worrying about polluting the system environment.
$ virtualenv Py-for-web
This creates a Python virtual environment called py-for-web, in effect cloning a python environment. You can then use the source Py-for-web/bin/activate command to update the terminal configuration and modify the environment variables. The next operation will only affect the py-for-web environment, you can use the PIP command to install the package here, of course, can also be installed directly.
$ source Py-for-web/bin/activate # Enable virtual environment
$ deactivate # exiting the virtual environment
There is a virtualenv-sh package, the virtualenv has done some enhancements to the terminal commands. After installation, add the configuration in ~/.BASHRC:
. /usr/local/bin/virtualenv-sh.bash
It provides several common commands such as:
Mkvirtualenv <env_name> Creating a virtual environment in $workon_home
Rmvirtualenv <env_name> Delete a virtual environment
Workon [<env_name>] Switch to the virtual environment
Deactivate exiting the virtual environment
Lsvirtualenvs List of all virtual environments
cdvirtualenv [SubDir] into the appropriate directory for the virtual environment
The default value for the $WORKON _home is ${home}/.virtualenvs.
Python installation package Setuptools Easy_install pip