关键字:python, win7, pygame,pip
今天想安装上pygame学习下。想直接用pip安装,出师不利,直接敲pip install pygame,直接报错pypi.python.org访问不了,貌似被墙了,汗啊
既然官方的源访问不了,只好百度大法,找找国内的源试试了。下面是网上一哥们收集的国内源,mark下
douban http://pypi.douban.com/simplePython官方 https://pypi.python.org/simplev2ex http://pypi.v2ex.com/simple清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
修改镜像源在不同操作系统中,修改文件的位置是不同的,
在linux默认的路径是$HOME/.pip/pip.conf在windows默认的路径是%HOME%\pip\pip.ini
默认路径下并不存在配置文件,需要新建,然后在配置文件中写入:
[global]index-url = http://pypi.mirrors.ustc.edu.cn/simple/
可是天不遂人愿。国内可以下载包,不过安装的时候报
C:\Users\fenmingp>pip install pygame -i --trusted-host http://mirrors.aliyun.com/pypi/simple/
Cannot unpack file c:\users\fenmingp\appdata\local\temp\pip-qcvul1-unpack\simple.html (downloaded from c:\users\fenmingp\appdata\local\temp\pip-rbahm2-build,
content-type: text/html); cannot detect archive format
Cannot determine archive format of c:\users\fenmingp\appdata\local\temp\pip-rbahm2-build
咱这个人还真是越挫越勇。又尝试直接去pygame的ftp目录下安装,还是报错,因为pygame里面还有C语言的一些实现,需要编译才能使用。但本人的windows系统编译环境有问题。
C:\Users\fenmingp>pip install http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz
error: command '"C:\Users\fenmingp\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe"' failed with exit status 2
源码安装无望了,乖乖下载编译好的windows安装文件吧。这次一路正常,官网下载后,直接安装好。
进入python,import pygame。 OK,没有报错,看来安装成功了。