您的位置:首页 > 编程语言 > Python开发

使用easy_install安装python包的方法 与python开源库

2016-03-09 11:50 716 查看
首先安装easy_install

easy_install 是 setuptools里的一个组件

安装easy_install 即是安装setuptools

链接https://pypi.python.org/pypi/setuptools




Download
ez_setup.py and run it using the target Python version. The scriptwill 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 toinstall 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

(一般第二个方法可以)



安装好之后使用easy_install 安装 

方法如下

For basic use of easy_install, you need only supply the filename or URL ofa source distribution or .egg file (Python
Egg).

Example 1. Install a package by name, searching PyPI for the latestversion, and automatically downloading, building, and installing it:

easy_install SQLObject

Example 2. Install or upgrade a package by name and version by findinglinks on a given "download page":

easy_install -f http://pythonpaste.org/package_index.html SQLObject

Example 3. Download a source distribution from a specified URL,automatically building and installing it:

easy_install http://example.com/path/to/MyPackage-1.2.3.tgz

Example 4. Install an already-downloaded .egg file:

easy_install /my_downloads/OtherPackage-3.2.1-py2.3.egg

Example 5. Upgrade an already-installed package to the latest versionlisted on PyPI:

easy_install --upgrade PyProtocols

Example 6. Install a source distribution that's already downloaded andextracted in the current directory (New in 0.5a9):

easy_install .

Example 7. (New in 0.6a1) Find a source distribution or Subversioncheckout URL for a package, and extract it or check it out to~/projects/sqlobject (the name will always be in all-lowercase),
where itcan be examined or edited. (The package will not be installed, but it caneasily be installed with
easy_install ~/projects/sqlobject. See

Editingand Viewing Source Packages below for more info.):

easy_install --editable --build-directory ~/projects SQLObject

Easy Install accepts URLs, filenames, PyPI package names (i.e.,
distutils"distribution" names), and package+version specifiers. In each case, it willattempt to locate the latest available version that meets your criteria.

When downloading or processing downloaded files, Easy Install recognizesdistutils source distribution files with extensions of .tgz, .tar, .tar.gz,.tar.bz2, or .zip. And of course it handles already-built .eggdistributions as well as
.win32.exe installers built using distutils.

By default, packages are installed to the running Python installation'ssite-packages directory, unless you provide the
-d or --install-diroption to specify an alternative directory, or specify an alternate locationusing distutils configuration files. (See

Configuration Files, below.)

By default, any scripts included with the package are installed to the runningPython installation's standard script installation location. However, if youspecify an installation directory via the command line or a config file, thenthe default directory for
installing scripts will be the same as the packageinstallation directory, to ensure that the script will have access to theinstalled package. You can override this using the
-s or --script-diroption.

Installed packages are added to an easy-install.pth file in the installdirectory, so that Python will always use the most-recently-installed versionof the package. If you would like to be able to select which
version to use atruntime, you should use the -m or
--multi-version option.

原文链接

http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install

大量的开源库 Python Package Index
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: