今天在安装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

最新文章

  1. SQL Server 2008 R2 未能加载文件或程序集Microsoft.SqlServer.Sqm...
  2. 安卓仿照QQ工单数实现
  3. 1008win7与虚拟机中的linux共享文件的(详细)方法
  4. Javascript 封装方法
  5. js 的一点用法
  6. HDU 2824 简单欧拉函数
  7. 演示save point及自治事务的用处
  8. innodb数据结构
  9. 揭秘Sql2014新特性-tempdb性能提升
  10. 薛非《品悟C-抛弃C程序设计中的谬误与恶习》读后感part1【转】
  11. dubbo源码之三——dubbo重构
  12. NOJ 1063 生活的烦恼
  13. UVALive 7464 Robots (贪心)
  14. centos 基本操作(输入法安装,adls宽带连接,查找文件,模拟终端)
  15. [认证授权] 2.OAuth2(续) & JSON Web Token
  16. firstChild,lastChild,nextSibling,previousSibling & 兼容性写法
  17. html页面不显示中文
  18. dede后台编辑器更改
  19. redis学习——数据持久化
  20. HashMap深度解析(转载)

热门文章

  1. 函数getpass
  2. JavaWeb学习篇--Filter过滤器
  3. spark historyserver 页面反应很慢 jvm堆调参
  4. Ubuntu下无法使用Secure_CRT连接服务器
  5. CSS样式学习-2
  6. day23-类的封装
  7. Spring boot 配置文件 加载顺序
  8. vue:监听数据
  9. php版本升级导致openssl无法使用
  10. Java中Asm包有什么用?