小编给大家分享一下Python中安装第三方模块的方法有哪些,相信大部分人都还不怎么了解,因此分享这边文章给大家学习,希望大家阅读完这篇文章后大所收获,下面让我们一起去学习方法吧!

安装Python第三方模块的方法有很多,这里介绍三种方法安装第三方模块。

【方法一】: 通过setuptools来安装python模块

首先下载 http://peak.telecommunity.com/dist/ez_setup.py

NOTE: 最好下载个setuptools,本人是15.2版本,里面包含了ez_setup

运行 python ez_setup.py

D:\work\installation\setuptools-15.2\setuptools-15.2>pythonez_setup.py>1.txtExtractinginc:\users\admini~1\appdata\local\temp\tmpbxikxfNowworkinginc:\users\admini~1\appdata\local\temp\tmpbxikxf\setuptools-15.2InstallingSetuptools......Copyingsetuptools-15.2-py2.7.eggtoc:\python27\lib\site-packagessetuptools15.2isalreadytheactiveversionineasy-install.pthInstallingeasy_install-script.pyscripttoC:\Python27\ScriptsInstallingeasy_install.exescripttoC:\Python27\ScriptsInstallingeasy_install-2.7-script.pyscripttoC:\Python27\ScriptsInstallingeasy_install-2.7.exescripttoC:\Python27\ScriptsInstalledc:\python27\lib\site-packages\setuptools-15.2-py2.7.eggProcessingdependenciesforsetuptools==15.2Finishedprocessingdependenciesforsetuptools==15.2

运行 easy_install py

D:\work>easy_installpy#py为第三方库文件SearchingforpyBestmatch:py1.4.26Addingpy1.4.26toeasy-install.pthfileUsingc:\python27\lib\site-packagesProcessingdependenciesforpyFinishedprocessingdependenciesforpy

【方法二】: 通过pip来安装python模块

安装 easy_install pip

D:\work>easy_installpipSearchingforpipBestmatch:pip6.1.1Processingpip-6.1.1-py2.7.eggpip6.1.1isalreadytheactiveversionineasy-install.pthInstallingpip-script.pyscripttoC:\Python27\ScriptsInstallingpip.exescripttoC:\Python27\ScriptsInstallingpip2.7-script.pyscripttoC:\Python27\ScriptsInstallingpip2.7.exescripttoC:\Python27\ScriptsInstallingpip2-script.pyscripttoC:\Python27\ScriptsInstallingpip2.exescripttoC:\Python27\ScriptsUsingc:\python27\lib\site-packages\pip-6.1.1-py2.7.eggProcessingdependenciesforpipFinishedprocessingdependenciesforpip

运行 pip install xlrd

Usage:pip<command></command>[options]Commands:installInstallpackages.uninstallUninstallpackages.freezeOutputinstalledpackagesinrequirementsformat.listListinstalledpackages.showShowinformationaboutinstalledpackages.searchSearchPyPIforpackages.wheelBuildwheelsfromyourrequirements.zipDEPRECATED.Zipindividualpackages.unzipDEPRECATED.Unzipindividualpackages.helpShowhelpforcommands.GeneralOptions:-h,--helpShowhelp.--isolatedRunpipinanisolatedmode,ignoringenvironmentvariablesanduserconfiguration.-v,--verboseGivemoreoutput.Optionisadditive,andcanbeusedupto3times.-V,--versionShowversionandexit.-q,--quietGivelessoutput.--log<path>Pathtoaverboseappendinglog.--proxy<proxy>Specifyaproxyintheform[user:passwd@]proxy.server:port.--retries<retries>Maximumnumberofretrieseachconnectionshouldattempt(default5times).--timeout<sec>Setthesockettimeout(default15seconds).--exists-action<action>Defaultactionwhenapathalreadyexists:(s)witch,(i)gnore,(w)ipe,(b)ackup.--trusted-host<hostname>Markthishostastrusted,eventhoughitdoesnothavevalidoranyHTTPS.--cert<path>PathtoalternateCAbundle.--client-cert<path>PathtoSSLclientcertificate,asinglefilecontainingtheprivatekeyandthecertificateinPEMformat.--cache-dir<dir>Storethecachedatain<dir>.--no-cache-dirDisablethecache.--disable-pip-version-checkDon'tperiodicallycheckPyPItodeterminewhetheranewversionofpipisavailablefordownload.Impliedwith--no-index.

【方法三】:直接从网上下载下可执行文件来安装.

比如说,去 >>> pythonlibs <<< 网站,提供了很多Python非官方包下载,二进制文件,下载安装方便.

以上是Python中安装第三方模块的方法有哪些的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!