Python安装第三方库的3种方法
【方法一】:通过setuptools来安装python模块
首先下载http://peak.telecommunity.com/dist/ez_setup.py
NOTE:最好下载个setuptools,本人是15.2版本,里面包含了ez_setup
运行pythonez_setup.py
D:\work\installation\setuptools-15.2\setuptools-15.2>pythonez_setup.py>1.txt Extractinginc:\users\admini~1\appdata\local\temp\tmpbxikxf Nowworkinginc:\users\admini~1\appdata\local\temp\tmpbxikxf\setuptools-15.2 InstallingSetuptools ...... Copyingsetuptools-15.2-py2.7.eggtoc:\python27\lib\site-packages setuptools15.2isalreadytheactiveversionineasy-install.pth Installingeasy_install-script.pyscripttoC:\Python27\Scripts Installingeasy_install.exescripttoC:\Python27\Scripts Installingeasy_install-2.7-script.pyscripttoC:\Python27\Scripts Installingeasy_install-2.7.exescripttoC:\Python27\Scripts Installedc:\python27\lib\site-packages\setuptools-15.2-py2.7.egg Processingdependenciesforsetuptools==15.2 Finishedprocessingdependenciesforsetuptools==15.2
运行easy_installpy
D:\work>easy_installpy#py为第三方库文件 Searchingforpy Bestmatch:py1.4.26 Addingpy1.4.26toeasy-install.pthfile Usingc:\python27\lib\site-packages Processingdependenciesforpy Finishedprocessingdependenciesforpy
【方法二】:通过pip来安装python模块
安装easy_installpip
D:\work>easy_installpip Searchingforpip Bestmatch:pip6.1.1 Processingpip-6.1.1-py2.7.egg pip6.1.1isalreadytheactiveversionineasy-install.pth Installingpip-script.pyscripttoC:\Python27\Scripts Installingpip.exescripttoC:\Python27\Scripts Installingpip2.7-script.pyscripttoC:\Python27\Scripts Installingpip2.7.exescripttoC:\Python27\Scripts Installingpip2-script.pyscripttoC:\Python27\Scripts Installingpip2.exescripttoC:\Python27\Scripts Usingc:\python27\lib\site-packages\pip-6.1.1-py2.7.egg Processingdependenciesforpip Finishedprocessingdependenciesforpip
运行pipinstallxlrd
Usage: pip<command>[options] Commands: installInstallpackages. uninstallUninstallpackages. freezeOutputinstalledpackagesinrequirementsformat. listListinstalledpackages. showShowinformationaboutinstalledpackages. searchSearchPyPIforpackages. wheelBuildwheelsfromyourrequirements. zipDEPRECATED.Zipindividualpackages. unzipDEPRECATED.Unzipindividualpackages. helpShowhelpforcommands. GeneralOptions: -h,--helpShowhelp. --isolatedRunpipinanisolatedmode,ignoring environmentvariablesanduserconfiguration. -v,--verboseGivemoreoutput.Optionisadditive,andcanbe usedupto3times. -V,--versionShowversionandexit. -q,--quietGivelessoutput. --log<path>Pathtoaverboseappendinglog. --proxy<proxy>Specifyaproxyintheform [user:passwd@]proxy.server:port. --retries<retries>Maximumnumberofretrieseachconnectionshould attempt(default5times). --timeout<sec>Setthesockettimeout(default15seconds). --exists-action<action>Defaultactionwhenapathalreadyexists: (s)witch,(i)gnore,(w)ipe,(b)ackup. --trusted-host<hostname>Markthishostastrusted,eventhoughitdoes nothavevalidoranyHTTPS. --cert<path>PathtoalternateCAbundle. --client-cert<path>PathtoSSLclientcertificate,asinglefile containingtheprivatekeyandthecertificate inPEMformat. --cache-dir<dir>Storethecachedatain<dir>. --no-cache-dirDisablethecache. --disable-pip-version-check Don'tperiodicallycheckPyPItodetermine whetheranewversionofpipisavailablefor download.Impliedwith--no-index.
【方法三】:直接从网上下载下可执行文件来安装.
比如说,去>>>pythonlibs<<<网站,提供了很多Python非官方包下载,二进制文件,下载安装方便.