使用setuptools简化Python模块的安装

如果说Perl用户 一定熟悉 CPAN,那么Python用户一定熟悉setuptools

默认activePython已经集成了这个工具,如果没有,可以在这里下载http://pypi.python.org/pypi/setuptools#downloads

用法:

cd /d E:\Python26\Scripts

easy_install 模块名

软件会自动联网下载安装,linux用法一样。

更多知识,参见IBM知识库 http://www.ibm.com/developerworks/cn/linux/l-cppeak3.html


实例 :安装SQLObject

E:\Python26\Scripts>easy_install SQLObject
install_dir E:\Python26\Lib\site-packages\
Searching for SQLObject
Reading http://pypi.python.org/simple/SQLObject/
Reading http://sqlobject.org
Reading http://sqlobject.org/
Reading http://sqlobject.org/devel/
Best match: SQLObject 0.14.0
Downloading http://pypi.python.org/packages/2.6/S/SQLObject/SQLObject-0.14.0-py2
.6.egg#md5=7ec52e2783cacf4edd714f16734a0d4e
Processing SQLObject-0.14.0-py2.6.egg
creating e:\python26\lib\site-packages\SQLObject-0.14.0-py2.6.egg
Extracting SQLObject-0.14.0-py2.6.egg to e:\python26\lib\site-packages
Adding SQLObject 0.14.0 to easy-install.pth file
Installing sqlobject-admin script to E:\Python26\Scripts
Installed e:\python26\lib\site-packages\sqlobject-0.14.0-py2.6.egg
Processing dependencies for SQLObject
Searching for FormEncode>=1.1.1
Reading http://pypi.python.org/simple/FormEncode/
Reading http://formencode.org
Reading http://formencode.sf.net
Best match: FormEncode 1.2.3dev
Downloading http://pypi.python.org/packages/source/F/FormEncode/FormEncode-1.2.3
dev.tar.gz#md5=c89a70812098bdeed27dc7c41be4f51e
Processing FormEncode-1.2.3dev.tar.gz
Running FormEncode-1.2.3dev\setup.py -q bdist_egg --dist-dir c:\docume~1\admini~
1\locals~1\temp\easy_install-cqnpss\FormEncode-1.2.3dev\egg-dist-tmp-p0kxxb
warning: no files found matching '*.py' under directory '.'
warning: no files found matching '*.html' under directory 'docs'
no previously-included directories found matching '**\.svn'
Adding formencode 1.2.3dev to easy-install.pth file
Installed e:\python26\lib\site-packages\formencode-1.2.3dev-py2.6.egg
Finished processing dependencies for SQLObject

然后 在Python里面import sqlobject 就可以使用了。

安装PyQuery也同理:(a jquery-like library for python)

C:\Users\ihipop>easy_install PyQuery
install_dir D:\Python26\Lib\site-packages\
Searching for PyQuery
Reading http://pypi.python.org/simple/PyQuery/
Reading http://www.bitbucket.org/olauzanne/pyquery/
Reading http://www.bitbucket.org/olauzanne/pyquery
Best match: pyquery 0.6.1
Downloading http://pypi.python.org/packages/source/p/pyquery/pyquery-0.6.1.zip#m
d5=348de0ff03451ef69f3a1098242c548c
Processing pyquery-0.6.1.zip
Running pyquery-0.6.1\setup.py -q bdist_egg --dist-dir c:\users\ihipop\appdata\l
ocal\temp\easy_install-stx4dh\pyquery-0.6.1\egg-dist-tmp-g7vrmw
Adding pyquery 0.6.1 to easy-install.pth file

Installed d:\python26\lib\site-packages\pyquery-0.6.1-py2.6.egg
Processing dependencies for PyQuery
Searching for lxml>=2.1
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.3beta1
Downloading http://pypi.python.org/packages/2.6/l/lxml/lxml-2.3beta1-py2.6-win32
.egg#md5=d4dafc94ae9543661e4c5722496d923d
Processing lxml-2.3beta1-py2.6-win32.egg
creating d:\python26\lib\site-packages\lxml-2.3beta1-py2.6-win32.egg
Extracting lxml-2.3beta1-py2.6-win32.egg to d:\python26\lib\site-packages
Adding lxml 2.3beta1 to easy-install.pth file

Installed d:\python26\lib\site-packages\lxml-2.3beta1-py2.6-win32.egg
Finished processing dependencies for PyQuery

完毕,多方便啊,这是一个python的小型包管理器了。
Author Info :
  • From:使用setuptools简化Python模块的安装
  • URL:https://blog.ihipop.com/2010/10/1719.html
  • Please Reserve This Link,Thanks!
  • 发表回复

    您的电子邮箱地址不会被公开。 必填项已用 * 标注