1.前言python
轉自:http://1boke.sinaapp.com/blog/4/13/app
不少時候咱們安裝函數庫的時候,最多見的方法是google,百度到函數庫的官方網站,而後選擇合適的版本下載並安裝,這個過程很煩人。函數
1boke接下來介紹的就是python包管理軟件easy_install。它的做用相似於Php中的pear,或者Ruby中的gem,或者Perl中的cpan。工具
若是想使用easy_install工具,可能須要先安裝setuptools,不過更酷的方法是使用 ez_setup.py 腳本:網站
1 |
python ez_setup.py |
2.下載google
http://peak.telecommunity.com/DevCenter/EasyInstallspa
安裝完後,最好確保easy_install所在目錄已經被加到PATH環境變量裏:code
1 |
Windows: C:\Python25\Scripts |
好比說要安裝Python的MySQL支持,能夠執行以下命令,系統會自動在pypi網站列表裏查找相關軟件包,並選擇合適的版本:blog
1 |
easy_install MySQL - python |
經過easy_install安裝軟件,相關安裝信息會保存到easy-install.pth文件裏,路徑相似以下形式:ip
1 |
Windows:C:\Python25\Lib\site - packages\ |
2 |
easy - install.pth |
若是想刪除經過easy_install安裝的軟件包,好比說:MySQL-python,能夠執行命令:
1 |
easy_install - m MySQL - python |
此操做會從easy-install.pth文件裏把MySQL-python的相關信息抹去,剩下的egg文件,你能夠手動刪除。對於已經下載了的python包,easy_install也能夠安裝,只要進入軟件包目錄,而後「easy_install .」便可更多使用方法參見peak上的介紹。
若是你在Windows+python2.5上執行如上命令的話,可能會出現以下錯誤:
Processing MySQL-python-1.2.3c1.tar.gz
Running MySQL-python-1.2.3c1\setup.py -q bdist_egg --dist-dir c:\docume~1\...
\locals~1\temp\easy_install-fvvfve\MySQL-python-1.2.3c1\egg-dist-tmp-q9moxf
error: The system cannot find the file specified
出現這類錯誤的緣由是選錯了版本,針對這個案列,咱們能夠顯式指定軟件包的版本號:
1 |
easy_install "MySQL-python==1.2.2" |