安装 pygame,找不到Python version 2.7
2024-09-08 12:25:17
今天在安装pygame时出错,提示“Python version 2.7 required, which was not found in the registry”,经过网上查找资料后发现只需要新建一个register.py文件就可以了。
新建文件,粘贴下面的内容:
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html
import sys
from _winreg import *
# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
)
def RegisterPy():
try:
reg = OpenKey(HKEY_CURRENT_USER, regpath)
except EnvironmentError as e:
try:
reg = CreateKey(HKEY_CURRENT_USER, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg)
except:
print "*** Unable to register!"
return
print "--- Python", version, "is now registered!"
return
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
CloseKey(reg)
print "=== Python", version, "is already registered!"
return
CloseKey(reg)
print "*** Unable to register!"
print "*** You probably have another Python installation!"
if __name__ == "__main__":
RegisterPy()
保存文件,命名为register.py,然后将该文件放到python的安装路径下,默认地址为:C:\Python27
然后重新双击pygame的安装包进行安装即可。
发布日期:2014-01-24 15:22
最新文章
- SQL Server 2008 R2 未能加载文件或程序集Microsoft.SqlServer.Sqm...
- 安卓仿照QQ工单数实现
- 1008win7与虚拟机中的linux共享文件的(详细)方法
- Javascript 封装方法
- js 的一点用法
- HDU 2824 简单欧拉函数
- 演示save point及自治事务的用处
- innodb数据结构
- 揭秘Sql2014新特性-tempdb性能提升
- 薛非《品悟C-抛弃C程序设计中的谬误与恶习》读后感part1【转】
- dubbo源码之三——dubbo重构
- NOJ 1063 生活的烦恼
- UVALive 7464	Robots (贪心)
- centos 基本操作(输入法安装,adls宽带连接,查找文件,模拟终端)
- [认证授权] 2.OAuth2(续) &; JSON Web Token
- firstChild,lastChild,nextSibling,previousSibling &; 兼容性写法
- html页面不显示中文
- dede后台编辑器更改
- redis学习——数据持久化
- HashMap深度解析(转载)