详解Python pygame安装过程笔记
今天看到一个教程,是关于Python安装pygame模块的。觉得很好,拿来分享一下。
安装Python
额,这个小题貌似在这里很是多余啊。但是为了照顾到刚刚学习Python的童鞋,我还是多啰嗦两句吧。
具体如下:
我们要到Python官网。去下载我们需要的版本。我这里下载的是windows64位的Python2.7msi。安装的过程如果不懂,选择为默认即可。
安装easy_install
至于这是个什么东东?我们大可不必劳心,现在只需要知道它能帮助我们安装一些库就可以了。具体的安装过程也很简单,只需要下载这个库,使用python的命令进行安装即可。
安装pip
好了,经过了前面的两步,想必大家(尤其是刚入门的童鞋)肯定会很心烦了吧,怎么需要装这么多的东西。但是咧,千万不要灰心,因为好日子马上就要来了。pip就是这么一款能解放你安装库的复杂劳动的一款神器。下面就一起来看一看怎么安装pip吧。
在此之前,一定要确认你的windows系统中已经安装好了Python和easy_install。
安装成功的标志:
MicrosoftWindows[版本6.1.7600] 版权所有(c)2009MicrosoftCorporation。保留所有权利。 C:\Users\Administrator>python Python2.7.11(v2.7.11:6d1b6a68f775,Dec52015,20:40:30)[MSCv.150064bit( AMD64)]onwin32 Type"help","copyright","credits"or"license"formoreinformation. >>>exit() C:\Users\Administrator>easy_install-version usage:easy_install[options]requirement_or_url... or:easy_install--help error:option-rnotrecognized C:\Users\Administrator>
接下来就是把目录切换到python的安装目录下的Script文件夹下,输入
easy_installpip。当然了如果要想方便一些的话,可以把这个路径配置到你的环境变量中(至于怎么配,网上的相关教程很多也很详细。我就不重复的造轮子了)。
验证一下:
C:\Users\Administrator>pip-v Usage: pip[options] Commands: installInstallpackages. downloadDownloadpackages. uninstallUninstallpackages. freezeOutputinstalledpackagesinrequirementsformat. listListinstalledpackages. showShowinformationaboutinstalledpackages. searchSearchPyPIforpackages. wheelBuildwheelsfromyourrequirements. hashComputehashesofpackagearchives. completionAhelpercommandusedforcommandcompletion helpShowhelpforcommands. GeneralOptions: -h,--helpShowhelp. --isolatedRunpipinanisolatedmode,ignoring environmentvariablesanduserconfiguration. -v,--verboseGivemoreoutput.Optionisadditive,andcanbe usedupto3times. -V,--versionShowversionandexit. -q,--quietGivelessoutput. --log Pathtoaverboseappendinglog. --proxy Specifyaproxyintheform [user:passwd@]proxy.server:port. --retries Maximumnumberofretrieseachconnectionshould attempt(default5times). --timeout Setthesockettimeout(default15seconds). --exists-action Defaultactionwhenapathalreadyexists: (s)witch,(i)gnore,(w)ipe,(b)ackup. --trusted-host Markthishostastrusted,eventhoughitdoes nothavevalidoranyHTTPS. --cert PathtoalternateCAbundle. --client-cert PathtoSSLclientcertificate,asinglefile containingtheprivatekeyandthecertificate inPEMformat. --cache-dir Storethecachedatain . --no-cache-dirDisablethecache. --disable-pip-version-check Don'tperiodicallycheckPyPItodetermine whetheranewversionofpipisavailablefor download.Impliedwith--no-index. C:\Users\Administrator>
安装pygame
安装pygame的前提那肯定是先得下载这个文件啊。所以我们需要下载一下。pygame文件下载。记得对应你的Python版本进行下载哦。
下载完之后我们会发现它是一个.whl后缀的文件。这就比较尴尬了。怎么打开呢?
答案就是使用另一款工具,wheel。wheel本质上是一个zip包格式,它使用.whl扩展名,用于python模块的安装,它的出现是为了替代Eggs。wheel还提供了一个bdist_wheel作为setuptools的扩展命令,这个命令可以用来生成wheel包。wheel一下,检查是否安装成功。
安装wheel的方式这次就爽多了。因为我们已经有了pip。
pipinstallwheel。搞定了。
现在回过头来进到pygameXXXXX.whl的目录下,wheel文件名.好了,彻底搞定了。
验证一下
C:\Users\Administrator>python Python2.7.11(v2.7.11:6d1b6a68f775,Dec52015,20:40:30)[MSCv.150064bit( AMD64)]onwin32 Type"help","copyright","credits"or"license"formoreinformation. >>>importpygame >>>
木有报错,这就说明咱安装成功了。接下来就开始愉快的pygame之旅吧。
总结
整体的安装过程是很让人纠结的。尤其是对那些刚入门的童鞋。但是,这也是最有价值的经验了。因为这些库的安装会让你对Python的架构更加的熟悉。整体结构的把握也会更加的好。
所以,静下心来。一步一步的,进行操作就是了。相信这会对你Python有很大的帮助的。也希望大家多多支持毛票票。