將python2.7添加進(jìn)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添加進(jìn)64位系統(tǒng)的注冊表方式就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
對Python3中bytes和HexStr之間的轉(zhuǎn)換詳解
今天小編就為大家分享一篇對Python3中bytes和HexStr之間的轉(zhuǎn)換詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-12-12
Python configparser模塊配置文件解析與應(yīng)用探究
在Python中,configparser模塊是用于處理配置文件的重要工具,本文將全面探討configparser模塊的使用方法,包括讀取、修改、寫入配置文件,以及如何在實際項目中應(yīng)用該模塊,結(jié)合豐富的示例代碼,將深入剖析該模塊的功能和靈活性2024-01-01
全網(wǎng)最新用python實現(xiàn)各種文件類型轉(zhuǎn)換的方法
這篇文章主要介紹了用python實現(xiàn)各種文件類型轉(zhuǎn)換的方法,包括word轉(zhuǎn)pdf,excel轉(zhuǎn)pdf,ppt轉(zhuǎn)pdf,本文通過實例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-05-05
Python?內(nèi)置函數(shù)sorted()的用法
這篇文章主要介紹了Python?內(nèi)置函數(shù)sorted()的用法,文章內(nèi)容介紹詳細(xì)具有一的參考價值,需要的小伙伴可以參考一下,希望對你的學(xué)習(xí)有所幫助2022-03-03
關(guān)于Python中的向量相加和numpy中的向量相加效率對比
今天小編就為大家分享一篇關(guān)于Python中的向量相加和numpy中的向量相加效率對比,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-08-08

