详解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 相关文章推荐
Python操作sqlite3快速、安全插入数据(防注入)的实例
Apr 26 Python
python获取从命令行输入数字的方法
Apr 29 Python
读写json中文ASCII乱码问题的解决方法
Nov 05 Python
python dataframe astype 字段类型转换方法
Apr 11 Python
Django框架的使用教程路由请求响应的方法
Jul 03 Python
Python实现的括号匹配判断功能示例
Aug 25 Python
Python多进程写入同一文件的方法
Jan 14 Python
使用 Python 玩转 GitHub 的贡献板(推荐)
Apr 04 Python
python3 dict ndarray 存成json,并保留原数据精度的实例
Dec 06 Python
使用python自动追踪你的快递(物流推送邮箱)
Mar 17 Python
Ubuntu18.04安装 PyCharm并使用 Anaconda 管理的Python环境
Apr 08 Python
matplotlib教程——强大的python作图工具库
Oct 15 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 strtok()函数的优点分析
2010/03/02 PHP
php实现用户在线时间统计详解
2011/10/08 PHP
解析php中curl_multi的应用
2013/07/17 PHP
Mootools 图片展示插件(lightbox,ImageMenu)收集集合
2010/05/21 Javascript
IE下window.onresize 多次调用与死循环bug处理方法介绍
2013/11/12 Javascript
jquery 漂亮的删除确认和提交无刷新删除示例
2013/11/13 Javascript
jquery遍历select元素(实例讲解)
2013/12/31 Javascript
js 赋值包含单引号双引号问题的解决方法
2014/02/26 Javascript
javascript实现限制上传文件大小
2015/02/06 Javascript
JavaScript通过setTimeout实时显示当前时间的方法
2015/04/16 Javascript
Nodejs初级阶段之express
2015/11/23 NodeJs
Bootstrap3.0学习教程之JS折叠插件
2016/05/27 Javascript
通过BootStrap实现轮播图的实际应用
2016/09/26 Javascript
9个让JavaScript调试更简单的Console命令
2016/11/14 Javascript
socket.io实现在线群聊功能
2017/04/07 Javascript
Angular 4.x 动态创建表单实例
2017/04/25 Javascript
ES6正则表达式的一些新功能总结
2017/05/09 Javascript
React Native中的RefreshContorl下拉刷新使用
2017/10/09 Javascript
vue.js实现点击后动态添加class及删除同级class的实现代码
2018/04/04 Javascript
Vue 监听列表item渲染事件方法
2018/09/06 Javascript
Vue路由管理器Vue-router的使用方法详解
2020/02/05 Javascript
Python的Bottle框架中返回静态文件和JSON对象的方法
2015/04/30 Python
对python append 与浅拷贝的实例讲解
2018/05/04 Python
Python快速查找list中相同部分的方法
2018/06/27 Python
PYTHON发送邮件YAGMAIL的简单实现解析
2019/10/28 Python
C面试题
2015/10/08 面试题
大学学年自我鉴定
2013/10/28 职场文书
总经理助理岗位职责
2013/11/08 职场文书
普师专业个人自荐信范文
2013/11/26 职场文书
股权转让协议书范本
2014/04/12 职场文书
关心下一代工作先进事迹
2014/08/15 职场文书
2014年小学安全工作总结
2014/12/04 职场文书
公务员个人考察材料
2014/12/23 职场文书
本科毕业论文指导教师评语
2014/12/30 职场文书
工作表扬信
2015/01/17 职场文书
导游词范文之颐和园/重庆/云台山
2019/09/10 职场文书