将python2.7添加进64位系统的注册表方式
2019-11-22 12:07
896 查看
解决问题:python2.7无法在注册表中被识别,即在安装NumPy和SciPy等出现“python version 2.7 required, which was not found in register”的问题。
解决方法:新建一个“register.py”的文件,复制以下内容,通过powershell的命令“python register.py”运行,看到“Python 2.7 is now registered!”即可。
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()
以上这篇将python2.7添加进64位系统的注册表方式就是小编分享给大家的全部内容了,希望能给大家一个参考
您可能感兴趣的文章:
相关文章推荐
- 将python2.7 添加进64位系统 的注册表
- 将python2.7添加进64位系统的注册表方法
- python2.7版本win7 64位系统安装pandas注意事项_20161226
- 《转载》WIN10 64位系统 32位Python2.7 PIL安装
- win10 64位系统下 python2.7环境 scrapy的部署
- python2.7版本在win7、64位系统安装遇到的问题
- WIN10 64位系统 32位Python2.7 PIL安装
- 64位系统使用reg add添加注册表信息时被重定向
- 关于win10 64位系统下vs2013与python2.7环境下caffe的配置工作入门工作总结
- 将python 添加进64位win7 的注册表
- 模块替换方式实现添加系统调用
- Linux下chkconfig命令详解即添加服务以及两种方式启动关闭系统服务
- Python2.7 64位 安装
- Python基础教程实践2,画幅好画(win7,64位系统)
- VB的32位程序在64位系统中出现文件和注册表自动转向的解决方法
- Python Windows中将Python添加到注册表中
- win7-64位系统用QSettings写注册表
- aop为系统添加操作日志,注入或配置声明的方式来实现
- Python调用系统命令的两种方式
- python 以面向对象的方式创建线程 实现售票系统