详解Python pygame安装过程笔记


Posted in Python onJune 05, 2017

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

安装Python

额,这个小题貌似在这里很是多余啊。但是为了照顾到刚刚学习Python的童鞋,我还是多??铝骄浒伞?/p>

具体如下:

我们要到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:\Users\Administrator>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (
AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

C:\Users\Administrator>easy_install -version
usage: easy_install [options] requirement_or_url ...
  or: easy_install --help

error: option -r not recognized

C:\Users\Administrator>

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

验证一下:

C:\Users\Administrator>pip -v

Usage:
 pip <command> [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>        Path to a verbose appending log.
 --proxy <proxy>       Specify a proxy in the form
               [user:passwd@]proxy.server:port.
 --retries <retries>     Maximum number of retries each connection should
               attempt (default 5 times).
 --timeout <sec>       Set the socket timeout (default 15 seconds).
 --exists-action <action>  Default action when a path already exists:
               (s)witch, (i)gnore, (w)ipe, (b)ackup.
 --trusted-host <hostname>  Mark this host as trusted, even though it does
               not have valid or any HTTPS.
 --cert <path>        Path to alternate CA bundle.
 --client-cert <path>    Path to SSL client certificate, a single file
               containing the private key and the certificate
               in PEM format.
 --cache-dir <dir>      Store the cache data in <dir>.
 --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:\Users\Administrator>

安装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:\Users\Administrator>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (
AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>>

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

总结

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

所以,静下心来。一步一步的,进行操作就是了。相信这会对你Python有很大的帮助的。也希望大家多多支持三水点靠木。

Python 相关文章推荐
分享15个最受欢迎的Python开源框架
Jul 13 Python
Python实现Windows上气泡提醒效果的方法
Jun 03 Python
python登录豆瓣并发帖的方法
Jul 08 Python
谈谈Python进行验证码识别的一些想法
Jan 25 Python
详解python中的线程
Feb 10 Python
python实现批量按比例缩放图片效果
Mar 30 Python
实例分析python3实现并发访问水平切分表
Sep 29 Python
pandas如何处理缺失值
Jul 31 Python
Python使用微信itchat接口实现查看自己微信的信息功能详解
Aug 22 Python
Python整数与Numpy数据溢出问题解决
Sep 11 Python
python如何实时获取tcpdump输出
Sep 16 Python
Python正则表达式中flags参数的实例详解
Apr 01 Python
Python编程实现双击更新所有已安装python模块的方法
Jun 05 #Python
CentOS 6.5下安装Python 3.5.2(与Python2并存)
Jun 05 #Python
Python实现随机生成有效手机号码及身份证功能示例
Jun 05 #Python
Python中模块pymysql查询结果后如何获取字段列表
Jun 05 #Python
Python实现选择排序
Jun 04 #Python
Python使用pymysql小技巧
Jun 04 #Python
Python常见异常分类与处理方法
Jun 04 #Python
You might like
PHP缓存技术的多种方法小结
2012/08/14 PHP
php随机生成数字字母组合的方法
2015/03/18 PHP
codeigniter显示所有脚本执行时间的方法
2015/03/21 PHP
PHP使用strstr()函数获取指定字符串后所有字符的方法
2016/01/07 PHP
PHP 图片合成、仿微信群头像的方法示例
2019/10/25 PHP
BOOM vs RR BO3 第一场2.13
2021/03/10 DOTA
jQuery学习7 操作JavaScript对象和集合的函数
2010/02/07 Javascript
javascript:FF/Chrome与IE动态加载元素的区别说明
2014/01/26 Javascript
jQuery实现渐变下拉菜单的简单方法
2015/03/11 Javascript
JS拖拽组件学习使用
2016/01/19 Javascript
详解Html a标签中href和onclick用法、区别、优先级别
2017/01/16 Javascript
Node.js 8 中的 util.promisify的详解
2017/06/12 Javascript
layui框架与SSM前后台交互的方法
2019/09/12 Javascript
jquery css实现流程进度条
2020/03/26 jQuery
小程序瀑布流组件实现翻页与图片懒加载
2020/05/19 Javascript
基于JQuery和DWR实现异步数据传递
2020/10/16 jQuery
Python3实现生成随机密码的方法
2014/08/23 Python
删除DataFrame中值全为NaN或者包含有NaN的列或行方法
2018/11/06 Python
Python获取时间范围内日期列表和周列表的函数
2019/08/05 Python
python爬虫selenium和phantomJs使用方法解析
2019/08/08 Python
python数据处理之如何选取csv文件中某几行的数据
2019/09/02 Python
Python实现aes加密解密多种方法解析
2020/05/15 Python
Python 的 __str__ 和 __repr__ 方法对比
2020/09/02 Python
使用CSS3制作倾斜导航条和毛玻璃效果
2017/09/12 HTML / CSS
css3实现书本翻页效果的示例代码
2021/03/08 HTML / CSS
土耳其风格手工珠宝:Ottoman Hands
2019/07/26 全球购物
大学毕业生工作的自我评价
2013/10/01 职场文书
公司会计岗位职责
2014/02/13 职场文书
活动总结格式
2014/08/30 职场文书
营业员岗位职责
2015/02/11 职场文书
留学推荐信怎么写
2015/03/26 职场文书
2016年中秋节慰问信
2015/12/01 职场文书
Django项目配置Memcached和Redis, 缓存选择哪个更有优势
2021/04/06 Python
Go语言操作数据库及其常规操作的示例代码
2021/04/21 Golang
星际争霸:毕姥爷vs解冻01
2022/04/01 星际争霸
Redis实现主从复制方式(Master&Slave)
2022/06/21 Redis