python安装第三方库一般方式和easy_install方式

上一篇 / 下一篇  2013-07-16 22:11:40 / 个人分类:python

python安装第三方库一般方式和easy_install方式  


2010-06-24 17:43:53|  分类: Python |  标签:python  |字号 订阅

python安装第三方库

 

一般方式

 

下载压缩包,解压出来,找到setup.py文件

命令行下使用

X:\解压路径下> python setup.py install

完成后查看

F:\Python25\Lib\site-packages\

下面,会多一个目录

然后在 解释器里可以使用 import 目录名

 


有些不是直接目录名的

如 .egg 结尾的目录,会找里面除 EGG-INFO 外的另一个目录名,可以 import 这个目录名

 


 

easy_install方式

用于安装egg扩展名的包,egg可以认为就是zip,只是扩展名不同。

 

 

使用文档
下载
找到当前最新版 0.6c9 的压缩包
下载,解压,直到找到 setup.py 
命令行下定位到那个目录中进行安装:
X:\解压路径下> python setup.py install

会安装到 

F:\Python25\Scripts\

把这个路径追加到 系统环境变量 PATH 中

 

也可以 找到 ez_setup.py 

 

X:\解压路径下> ez_setup.py
这样会根据情况下载最新的easy_install

 

 


 

 

easy_install的一些用法

在命令行上 指定包的名称(会搜索PyPI)、指定包文件的网上路径、本地文件路径、当前目录 进行安装和更新

X:\> easy_install 路径

 

 

http://peak.telecommunity.com/DevCenter/EasyInstall

Downloading and Installing a Package

 

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

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

easy_install SQLObject

Example 2. Install or upgrade a package by name and version by finding links 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 version listed on PyPI:

easy_install --upgrade PyProtocols

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

easy_install .

Example 7. (New in 0.6a1) Find a source distribution or Subversion checkout URL for a package, and extract it or check it out to ~/projects/sqlobject (the name will always be in all-lowercase), where it can be examined or edited. (The package will not be installed, but it can easily be installed with easy_install ~/projects/sqlobject. See Editing and Viewing Source Packages below for more info.):

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

TAG:

 

评分:0

我来说两句

Open Toolbar