Python包管理中的簡(jiǎn)單化處理工具的介紹
假如你想對(duì)Python包管理變得阻礙實(shí)際操作中更為簡(jiǎn)單的話,你就可以使用easy_install工具對(duì)Python包管理進(jìn)行“搭配”easy_install此工具的作用類(lèi)似于Php中的pear,或者Ruby中的gem,或者Perl中的cpan。
如果想使用easy_install工具,可以直接安裝ez_setup.py腳本,再python ez_setup.py(之前先要安裝python):
安裝完后,最好確保easy_install所在目錄已經(jīng)被加到PATH環(huán)境變量里:
- Windows: C:\Python25\Scripts
- Linux: /usr/local/bin
比如說(shuō)要安裝Python的MySQL支持,可以執(zhí)行如下命令,系統(tǒng)會(huì)自動(dòng)在pypi網(wǎng)站列表里查找相關(guān)軟件包,并選擇合適的版本:
- easy_install MySQL-python
通過(guò)easy_install在包管理中安裝軟件,相關(guān)安裝信息會(huì)保存到easy-install.pth文件里,路徑類(lèi)似如下形式:
- Windows:C:\Python25\Lib\site-packages\
easy-install.pth- Linux:/usr/local/lib/python25/site-packages
/easy-install.pth
如果想刪除通過(guò)easy_install安裝的軟件包,比如說(shuō):MySQL-python,可以執(zhí)行命令:
- easy_install -m MySQL-python
此操作會(huì)從easy-install.pth文件里把MySQL-python的相關(guān)信息抹去,剩下的egg文件,你可以手動(dòng)刪除。對(duì)于已經(jīng)下載了的python包,easy_install也可以安裝,只要進(jìn)入軟件包目錄,然后“easy_install .”即可更多使用方法參見(jiàn)peak上的介紹
使用easy_install安裝python環(huán)境:
1、下載python2.5安裝文件安裝(最新的穩(wěn)定版,不要嘗試 python2.6或3.0,因?yàn)樵S多py包還不支持)#t#
2、下載pyreadline可執(zhí)行文件安裝
3、下載ez_install.py運(yùn)行
4、easy_install ipython ipy pylint django robotframework mechanize
5、不能使用easy_install的特殊情況:
a、安裝默認(rèn)版本的MySQL-python會(huì)報(bào)錯(cuò),需要指定版本如下:easy_install "MySQL-python==1.2.2"
b、有些包直接easy_install會(huì)失敗,需要自行下載安裝:
wxpython,pil要下載exe安裝程序robotide因?yàn)樵趐ypi上找不到,要下載后再easy_install。以上的內(nèi)容就是對(duì) easy_install使Python包管理變得簡(jiǎn)單的實(shí)際過(guò)程的相關(guān)介紹。