將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”運(yùn)行,看到“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 與python2 異常處理的區(qū)別與聯(lián)系
這篇文章主要介紹了python3 與python2 異常處理的區(qū)別與聯(lián)系的相關(guān)資料,需要的朋友可以參考下2016-06-06
python爬取盤搜的有效鏈接實(shí)現(xiàn)代碼
這篇文章主要介紹了python爬取盤搜的有效鏈接,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下2019-07-07
python進(jìn)行二次方程式計(jì)算的實(shí)例講解
在本篇內(nèi)容里小編給大家整理了一篇關(guān)于python進(jìn)行二次方程式計(jì)算的實(shí)例講解內(nèi)容,有興趣的朋友們可以學(xué)習(xí)下。2020-12-12
python3中類的繼承以及self和super的區(qū)別詳解
今天小編就為大家分享一篇python3中類的繼承以及self和super的區(qū)別詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06
Django admin管理工具TabularInline類用法詳解
這篇文章主要介紹了Django admin管理工具TabularInline類用法詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05
anaconda虛擬環(huán)境默認(rèn)路徑的更改圖文教程
在Anaconda中如果沒有指定路徑,虛擬環(huán)境會默認(rèn)安裝在anaconda所安裝的目錄下,這篇文章主要給大家介紹了關(guān)于anaconda虛擬環(huán)境默認(rèn)路徑更改的相關(guān)資料,需要的朋友可以參考下2023-10-10
uwsgi+nginx部署Django項(xiàng)目操作示例
這篇文章主要介紹了uwsgi+nginx部署Django項(xiàng)目操作,結(jié)合實(shí)例形式簡單介紹了uwsgi的概念、原理、安裝、項(xiàng)目創(chuàng)建、配置、調(diào)試運(yùn)行等相關(guān)操作技巧,需要的朋友可以參考下2018-12-12

