一 安装介绍:
安装地址:
The recommended way to bootstrap setuptools on any system is to download and run it using the target Python environment. Different operating systems have different recommended techniques to accomplish this basic routine, so below are some examples to get you started.
Setuptools requires Python 2.6 or later. To install setuptools on Python 2.4 or Python 2.5, use the.
The link provided to ez_setup.py is a bookmark to bootstrap script for the latest known stable release.
window安装:
For best results, uninstall previous versions FIRST (see ).
Using Windows 8 (which includes PowerShell 3) or earlier versions of Windows with PowerShell 3 installed, it’s possible to install with one simple Powershell command. Start up Powershell and paste this command:
> (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python -
You must start the Powershell with Administrative privileges or you may choose to install a user-local installation:
> (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python - --user
If you have Python 3.3 or later, you can use the py command to install to different Python versions. For example, to install to Python 3.3 if you have Python 2.7 installed:
> (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | py -3 -
The recommended way to install setuptools on Windows is to download and run it. The script will download the appropriate distribution file and install it for you.
Once installation is complete, you will find an easy_install program in your Python Scriptssubdirectory. For simple invocation and best results, add this directory to your PATH environment variable, if it is not already present. If you did a user-local install, the Scripts subdirectory is$env:APPDATA\Python\Scripts.
For Windows without PowerShell 3 or for installation without a command-line, download using your preferred web browser or other technique and “run” that file.
linux安装:
Most Linux distributions come with wget.
Download and run it using the target Python version. The script will download the appropriate version and install it for you:
> wget https://bootstrap.pypa.io/ez_setup.py -O - | python
Note that you will may need to invoke the command with superuser privileges to install to the system Python:
> wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
Alternatively, Setuptools may be installed to a user-local path:
> wget https://bootstrap.pypa.io/ez_setup.py -O - | python - --user
Note that on some older systems (noted on Debian 6 and CentOS 5 installations),wgetmay refuse to downloadez_setup.py, complaining that the certificate common name*.c.ssl.fastly.netdoes not match the host namebootstrap.pypa.io. In addition, theez_setup.pyscript may then encounter similar problems usingwgetinternally to downloadsetuptools-x.y.zip, complaining that the certificate common name ofwww.python.orgdoes not match the host namepypi.python.org. Those are known issues, related to a bug in the older versions ofwget(see ). If you happen to encounter them, install Setuptools as follows:
> wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py> python ez_setup.py --insecure
mac安装:
If your system has curl installed, follow the wget instructions but replace wget with curl and -O with-o. For example:
> curl https://bootstrap.pypa.io/ez_setup.py -o - | python
自定义安装:
For more advanced installation options, such as installing to custom locations or prefixes, download and extract the source tarball from and run setup.py with any supported distutils and Setuptools options. For example:
setuptools-x.x$ python setup.py install --prefix=/opt/setuptools
Use --help to get a full options list, but we recommend consulting the for detailed instructions, especially .
二 演示:
主机版本:
[root@master progressbar-2.3]# cat /etc/centos-release
CentOS release 6.7 (Final)安装:
[root@master progressbar-2.3]# wget -O - | python
--2016-01-11 07:15:01-- Resolving bootstrap.pypa.io... 185.31.18.175 Connecting to bootstrap.pypa.io|185.31.18.175|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 12059 (12K) [text/x-python] Saving to: “STDOUT”100%[===========================================>] 12,059 --.-K/s in 0s
2016-01-11 07:15:09 (432 MB/s) - written to stdout [12059/12059]
Downloading
Extracting in /tmp/tmpQGjSJl Now working in /tmp/tmpQGjSJl/setuptools-19.2 Installing Setuptools running install running bdist_egg running egg_info writing requirements to setuptools.egg-info/requires.txt writing setuptools.egg-info/PKG-INFO writing top-level names to setuptools.egg-info/top_level.txt writing dependency_links to setuptools.egg-info/dependency_links.txt writing entry points to setuptools.egg-info/entry_points.txt reading manifest file 'setuptools.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'setuptools.egg-info/SOURCES.txt' installing library code to build/bdist.linux-i686/egg running install_lib running build_py creating build creating build/lib copying easy_install.py -> build/lib creating build/lib/setuptools copying setuptools/site-patch.py -> build/lib/setuptools copying setuptools/utils.py -> build/lib/setuptools copying setuptools/__init__.py -> build/lib/setuptools copying setuptools/package_index.py -> build/lib/setuptools copying setuptools/ssl_support.py -> build/lib/setuptools copying setuptools/version.py -> build/lib/setuptools copying setuptools/msvc9_support.py -> build/lib/setuptools copying setuptools/py27compat.py -> build/lib/setuptools copying setuptools/compat.py -> build/lib/setuptools copying setuptools/extension.py -> build/lib/setuptools copying setuptools/windows_support.py -> build/lib/setuptools copying setuptools/unicode_utils.py -> build/lib/setuptools copying setuptools/py31compat.py -> build/lib/setuptools copying setuptools/py26compat.py -> build/lib/setuptools copying setuptools/archive_util.py -> build/lib/setuptools copying setuptools/dist.py -> build/lib/setuptools copying setuptools/sandbox.py -> build/lib/setuptools copying setuptools/lib2to3_ex.py -> build/lib/setuptools copying setuptools/depends.py -> build/lib/setuptools creating build/lib/_markerlib copying _markerlib/__init__.py -> build/lib/_markerlib copying _markerlib/markers.py -> build/lib/_markerlib creating build/lib/pkg_resources copying pkg_resources/__init__.py -> build/lib/pkg_resources creating build/lib/setuptools/command copying setuptools/command/rotate.py -> build/lib/setuptools/command copying setuptools/command/easy_install.py -> build/lib/setuptools/command copying setuptools/command/__init__.py -> build/lib/setuptools/command copying setuptools/command/setopt.py -> build/lib/setuptools/command copying setuptools/command/build_py.py -> build/lib/setuptools/command copying setuptools/command/build_ext.py -> build/lib/setuptools/command copying setuptools/command/install_egg_info.py -> build/lib/setuptools/command copying setuptools/command/install_scripts.py -> build/lib/setuptools/command copying setuptools/command/sdist.py -> build/lib/setuptools/command copying setuptools/command/bdist_wininst.py -> build/lib/setuptools/command copying setuptools/command/bdist_rpm.py -> build/lib/setuptools/command copying setuptools/command/test.py -> build/lib/setuptools/command copying setuptools/command/install.py -> build/lib/setuptools/command copying setuptools/command/saveopts.py -> build/lib/setuptools/command copying setuptools/command/egg_info.py -> build/lib/setuptools/command copying setuptools/command/register.py -> build/lib/setuptools/command copying setuptools/command/bdist_egg.py -> build/lib/setuptools/command copying setuptools/command/develop.py -> build/lib/setuptools/command copying setuptools/command/install_lib.py -> build/lib/setuptools/command copying setuptools/command/alias.py -> build/lib/setuptools/command copying setuptools/command/upload_docs.py -> build/lib/setuptools/command creating build/lib/pkg_resources/_vendor copying pkg_resources/_vendor/__init__.py -> build/lib/pkg_resources/_vendor creating build/lib/pkg_resources/_vendor/packaging copying pkg_resources/_vendor/packaging/specifiers.py -> build/lib/pkg_resources/_vendor/packaging copying pkg_resources/_vendor/packaging/__init__.py -> build/lib/pkg_resources/_vendor/packaging copying pkg_resources/_vendor/packaging/version.py -> build/lib/pkg_resources/_vendor/packaging copying pkg_resources/_vendor/packaging/_compat.py -> build/lib/pkg_resources/_vendor/packaging copying pkg_resources/_vendor/packaging/_structures.py -> build/lib/pkg_resources/_vendor/packaging copying pkg_resources/_vendor/packaging/__about__.py -> build/lib/pkg_resources/_vendor/packaging copying setuptools/script (dev).tmpl -> build/lib/setuptools copying setuptools/script.tmpl -> build/lib/setuptools creating build/bdist.linux-i686 creating build/bdist.linux-i686/egg copying build/lib/easy_install.py -> build/bdist.linux-i686/egg creating build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/site-patch.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/utils.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/__init__.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/script (dev).tmpl -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/package_index.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/ssl_support.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/version.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/msvc9_support.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/py27compat.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/compat.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/extension.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/windows_support.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/unicode_utils.py -> build/bdist.linux-i686/egg/setuptools creating build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/rotate.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/easy_install.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/__init__.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/setopt.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/build_py.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/build_ext.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/install_egg_info.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/install_scripts.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/sdist.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/bdist_wininst.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/bdist_rpm.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/test.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/install.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/saveopts.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/egg_info.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/register.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/bdist_egg.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/develop.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/install_lib.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/alias.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/command/upload_docs.py -> build/bdist.linux-i686/egg/setuptools/command copying build/lib/setuptools/script.tmpl -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/py31compat.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/py26compat.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/archive_util.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/dist.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/sandbox.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/lib2to3_ex.py -> build/bdist.linux-i686/egg/setuptools copying build/lib/setuptools/depends.py -> build/bdist.linux-i686/egg/setuptools creating build/bdist.linux-i686/egg/_markerlib copying build/lib/_markerlib/__init__.py -> build/bdist.linux-i686/egg/_markerlib copying build/lib/_markerlib/markers.py -> build/bdist.linux-i686/egg/_markerlib creating build/bdist.linux-i686/egg/pkg_resources copying build/lib/pkg_resources/__init__.py -> build/bdist.linux-i686/egg/pkg_resources creating build/bdist.linux-i686/egg/pkg_resources/_vendor copying build/lib/pkg_resources/_vendor/__init__.py -> build/bdist.linux-i686/egg/pkg_resources/_vendor creating build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging copying build/lib/pkg_resources/_vendor/packaging/specifiers.py -> build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging copying build/lib/pkg_resources/_vendor/packaging/__init__.py -> build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging copying build/lib/pkg_resources/_vendor/packaging/version.py -> build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging copying build/lib/pkg_resources/_vendor/packaging/_compat.py -> build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging copying build/lib/pkg_resources/_vendor/packaging/_structures.py -> build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging copying build/lib/pkg_resources/_vendor/packaging/__about__.py -> build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging byte-compiling build/bdist.linux-i686/egg/easy_install.py to easy_install.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/site-patch.py to site-patch.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/utils.py to utils.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/__init__.py to __init__.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/package_index.py to package_index.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/ssl_support.py to ssl_support.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/version.py to version.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/msvc9_support.py to msvc9_support.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/py27compat.py to py27compat.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/compat.py to compat.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/extension.py to extension.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/windows_support.py to windows_support.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/unicode_utils.py to unicode_utils.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/rotate.py to rotate.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/easy_install.py to easy_install.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/__init__.py to __init__.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/setopt.py to setopt.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/build_py.py to build_py.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/build_ext.py to build_ext.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/install_egg_info.py to install_egg_info.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/install_scripts.py to install_scripts.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/sdist.py to sdist.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/bdist_wininst.py to bdist_wininst.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/bdist_rpm.py to bdist_rpm.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/test.py to test.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/install.py to install.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/saveopts.py to saveopts.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/egg_info.py to egg_info.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/register.py to register.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/bdist_egg.py to bdist_egg.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/develop.py to develop.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/install_lib.py to install_lib.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/alias.py to alias.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/command/upload_docs.py to upload_docs.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/py31compat.py to py31compat.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/py26compat.py to py26compat.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/archive_util.py to archive_util.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/dist.py to dist.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/sandbox.py to sandbox.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/lib2to3_ex.py to lib2to3_ex.pyc byte-compiling build/bdist.linux-i686/egg/setuptools/depends.py to depends.pyc byte-compiling build/bdist.linux-i686/egg/_markerlib/__init__.py to __init__.pyc byte-compiling build/bdist.linux-i686/egg/_markerlib/markers.py to markers.pyc byte-compiling build/bdist.linux-i686/egg/pkg_resources/__init__.py to __init__.pyc byte-compiling build/bdist.linux-i686/egg/pkg_resources/_vendor/__init__.py to __init__.pyc byte-compiling build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging/specifiers.py to specifiers.pyc byte-compiling build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging/__init__.py to __init__.pyc byte-compiling build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging/version.py to version.pyc byte-compiling build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging/_compat.py to _compat.pyc byte-compiling build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging/_structures.py to _structures.pyc byte-compiling build/bdist.linux-i686/egg/pkg_resources/_vendor/packaging/__about__.py to __about__.pyc creating build/bdist.linux-i686/egg/EGG-INFO copying setuptools.egg-info/PKG-INFO -> build/bdist.linux-i686/egg/EGG-INFO copying setuptools.egg-info/SOURCES.txt -> build/bdist.linux-i686/egg/EGG-INFO copying setuptools.egg-info/dependency_links.txt -> build/bdist.linux-i686/egg/EGG-INFO copying setuptools.egg-info/entry_points.txt -> build/bdist.linux-i686/egg/EGG-INFO copying setuptools.egg-info/requires.txt -> build/bdist.linux-i686/egg/EGG-INFO copying setuptools.egg-info/top_level.txt -> build/bdist.linux-i686/egg/EGG-INFO copying setuptools.egg-info/zip-safe -> build/bdist.linux-i686/egg/EGG-INFO creating dist creating 'dist/setuptools-19.2-py2.6.egg' and adding 'build/bdist.linux-i686/egg' to it removing 'build/bdist.linux-i686/egg' (and everything under it) Processing setuptools-19.2-py2.6.egg Copying setuptools-19.2-py2.6.egg to /usr/lib/python2.6/site-packages Adding setuptools 19.2 to easy-install.pth file Installing easy_install script to /usr/bin Installing easy_install-2.6 script to /usr/binInstalled /usr/lib/python2.6/site-packages/setuptools-19.2-py2.6.egg
Processing dependencies for setuptools==19.2 Finished processing dependencies for setuptools==19.2验证:
[root@master progressbar-2.3]# easy_install pip
Searching for pip Reading Best match: pip 7.1.2 Downloading Processing pip-7.1.2.tar.gz Writing /tmp/easy_install-dAri8v/pip-7.1.2/setup.cfg Running pip-7.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-dAri8v/pip-7.1.2/egg-dist-tmp-PwaE1u warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.mailmap' warning: no previously-included files found matching '.travis.yml' warning: no previously-included files found matching 'pip/_vendor/Makefile' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'dev-requirements.txt' no previously-included directories found matching '.travis' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'contrib' no previously-included directories found matching 'tasks' no previously-included directories found matching 'tests' creating /usr/lib/python2.6/site-packages/pip-7.1.2-py2.6.egg Extracting pip-7.1.2-py2.6.egg to /usr/lib/python2.6/site-packages Adding pip 7.1.2 to easy-install.pth file Installing pip script to /usr/bin Installing pip2.6 script to /usr/bin Installing pip2 script to /usr/binInstalled /usr/lib/python2.6/site-packages/pip-7.1.2-py2.6.egg
Processing dependencies for pip Finished processing dependencies for pip [root@master progressbar-2.3]# echo $? 0三 使用说明:
easy_install 安裝與移除套件的基本使用方式如下:
安裝套件:
easy_install PackageName
更新套件:
easy_install -U PackageName
移除套件:
easy_install -m PackageName
顯示說明:
easy_install --showhelp
pip 安裝與移除套件的基本使用方式如下:
安裝套件:
pip install PackageName
更新套件:
pip install -U PackageName
移除套件:
pip uninstall PackageName
搜尋套件:
pip search PackageName
顯示說明:
pip help
本文出自 “” 博客,请务必保留此出处