Python pygame如何安装?详解Python pygame安装的教程实例

本篇文章主要介绍了详解python pygame安装过程笔记。小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

今天看到一个教程,是关于Python安装pygame模块的。觉得很好,拿来分享一下。

安装Python

额,这个小题貌似在这里很是多余啊。但是为了照顾到刚刚学习Python的童鞋,我还是多啰嗦两句吧。

具体如下:

立即学习“Python免费学习笔记(深入)”;

我们要到Python官网。去下载我们需要的版本。我这里下载的是windows64位 的Python2.7 msi。安装的过程如果不懂,选择为默认即可。

安装easy_install

至于这是个什么东东?我们大可不必劳心,现在只需要知道它能帮助我们安装一些库就可以了。具体的安装过程也很简单,只需要下载这个库,使用python的命令进行安装即可。

安装pip

好了,经过了前面的两步,想必大家(尤其是刚入门的童鞋)肯定会很心烦了吧,怎么需要装这么多的东西。但是咧,千万不要灰心,因为好日子马上就要来了。pip就是这么一款能解放你安装库的复杂劳动的一款神器。下面就一起来看一看怎么安装pip吧。

在此之前,一定要确认你的windows系统中已经安装好了Python和easy_install。

安装成功的标志:

Microsoft Windows [版本 6.1.7600]版权所有 (c) 2009 Microsoft Corporation。保留所有权利。C:UsersAdministrator>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> exit()C:UsersAdministrator>easy_install -versionusage: easy_install [options] requirement_or_url ...  or: easy_install --helperror: option -r not recognizedC:UsersAdministrator>

登录后复制

接下来就是把目录切换到python的安装目录下的Script文件夹下,输入
easy_install pip。当然了如果要想方便一些的话,可以把这个路径配置到你的环境变量中(至于怎么配,网上的相关教程很多也很详细。我就不重复的造轮子了)。

验证一下:

C:UsersAdministrator>pip -vUsage: pip  [options]Commands: install           Install packages. download          Download packages. uninstall          Uninstall packages. freeze           Output installed packages in requirements format. list            List installed packages. show            Show information about installed packages. search           Search PyPI for packages. wheel            Build wheels from your requirements. hash            Compute hashes of package archives. completion         A helper command used for command completion help            Show help for commands.General Options: -h, --help         Show help. --isolated         Run pip in an isolated mode, ignoring               environment variables and user configuration. -v, --verbose        Give more output. Option is additive, and can be               used up to 3 times. -V, --version        Show version and exit. -q, --quiet         Give less output. --log         Path to a verbose appending log. --proxy        Specify a proxy in the form               [user:passwd@]proxy.server:port. --retries      Maximum number of retries each connection should               attempt (default 5 times). --timeout        Set the socket timeout (default 15 seconds). --exists-action   Default action when a path already exists:               (s)witch, (i)gnore, (w)ipe, (b)ackup. --trusted-host   Mark this host as trusted, even though it does               not have valid or any HTTPS. --cert         Path to alternate CA bundle. --client-cert     Path to SSL client certificate, a single file               containing the private key and the certificate               in PEM format. --cache-dir       Store the cache data in . --no-cache-dir       Disable the cache. --disable-pip-version-check               Don't periodically check PyPI to determine               whether a new version of pip is available for               download. Implied with --no-index.C:UsersAdministrator>

登录后复制

安装pygame

安装pygame的前提那肯定是先得下载这个文件啊。所以我们需要下载一下。pygame 文件下载。记得对应你的Python版本进行下载哦。

下载完之后我们会发现它是一个.whl后缀的文件。这就比较尴尬了。怎么打开呢?

答案就是使用另一款工具,wheel。wheel 本质上是一个 zip 包格式,它使用 .whl 扩展名,用于 python 模块的安装,它的出现是为了替代 Eggs。wheel 还提供了一个 bdist_wheel 作为 setuptools 的扩展命令,这个命令可以用来生成 wheel 包。wheel一下,检查是否安装成功。

安装wheel的方式这次就爽多了。因为我们已经有了pip。

pip install wheel。搞定了。

现在回过头来进到pygameXXXXX.whl的目录下,wheel 文件名 .好了,彻底搞定了。

验证一下

C:UsersAdministrator>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import pygame>>>

登录后复制

木有报错,这就说明咱安装成功了。接下来就开始愉快的pygame之旅吧。

总结

整体的安装过程是很让人纠结的。尤其是对那些刚入门的童鞋。但是,这也是最有价值的经验了。因为这些库的安装会让你对Python的架构更加的熟悉。整体结构的把握也会更加的好。

以上就是Python pygame如何安装?详解Python pygame安装的教程实例的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2269613.html

(0)
上一篇 2025年2月27日 11:17:26
下一篇 2025年2月21日 13:08:31

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论