將python2.7添加進64位系統(tǒng)的注冊表方式
解決問題:python2.7無法在注冊表中被識別,即在安裝NumPy和SciPy等出現(xiàn)“python version 2.7 required, which was not found in register”的問題。
解決方法:新建一個“register.py”的文件,復(fù)制以下內(nèi)容,通過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位系統(tǒng)的注冊表方式就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
python3 與python2 異常處理的區(qū)別與聯(lián)系
這篇文章主要介紹了python3 與python2 異常處理的區(qū)別與聯(lián)系的相關(guān)資料,需要的朋友可以參考下2016-06-06
python3中類的繼承以及self和super的區(qū)別詳解
今天小編就為大家分享一篇python3中類的繼承以及self和super的區(qū)別詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06
Django admin管理工具TabularInline類用法詳解
這篇文章主要介紹了Django admin管理工具TabularInline類用法詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05

