python修复不了_修复 Python version 2.6 required, which was not found in the registry.
如下:
Portable Python是可移植的Python開發環境,它允許同一個系統環境下并存多個版本且相互獨立的Python開發環境,也適合放在移動存儲設備中作為一個完備的的、便攜的開發環境,這兩個特點對開發人員非常有用。Portable Python集成了wxPython、django、PyGame等一批常用的Python框架和模塊,甚至內含了PyScripter、SPE這兩個Python的IDE,這使得Portable Python自解壓到硬盤上開始就是一個完備的Python開發環境!
但是由于是可移植的,Portable Python并不會像Python官方的Windows平臺安裝程序一樣在安裝時往注冊表中寫入相關信息。同時,一些工具的安裝或運行需要讀取注冊表中的Python信息,比如win32all安裝程序和使用distutils包制作的安裝程序。SQLite的Python移植版PySQLite的Windows平臺安裝程序就是使用distutils制作的,我在安裝適用于Python 2.6的PySQLite到Portable Python時就因收到"Python version 2.6 required, which was not found in the registry."的錯誤而失敗。
這里提供了解決辦法,首先,將下面的代碼復制并保存為一個Python文件(比如registerpython.py):
#!/usr/bin/python
# -*- encoding: utf-8 -*-
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim L?w for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
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_LOCAL_MACHINE, regpath)
except EnvironmentError:
try:
reg = CreateKey(HKEY_LOCAL_MACHINE, 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!"
def UnRegisterPy():
try:
reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
except EnvironmentError:
print "*** Python not registered?!"
return
try:
DeleteKey(reg, installkey)
DeleteKey(reg, pythonkey)
DeleteKey(HKEY_LOCAL_MACHINE, regpath)
except:
print "*** Unable to un-register!"
else:
print "--- Python", version, "is no longer registered!"
if __name__ == "__main__":
# Register python's distribution
RegisterPy()
# If you want to unregister python's distribution, just comment the upper line and uncomment the following line
#UnRegisterPy()
然后在Windows的cmd.exe中使用Portable Python的python.exe執行此腳本,例如我這里是:
D:\PortablePython1.1py2.6.1\App\python.exe D:\registerpython.py
執行后,正常情況下應該可以成功向注冊表中寫入相關信息,此時再安裝PySQLite或其它依賴注冊表中Python安裝信息的程序就正常了。安裝后的PySQLite已經不需要注冊表,如果希望刪除注冊表中的信息,可以根據上面代碼中的注釋的說明,將"RegisterPy()"這一行注釋掉,而去掉"UnRegisterPy()"前面的注釋符號,然后再執行即可。
他是這么說的:
I realize this question is a year old - but I thought I would contribute one additional bit of info in case anyone else is Googling for this answer.
The issue only crops up on Win7 64-bit when you install Python "for all users". If you install it "for just me", you should not receive these errors. It seems that a lot of installers only look under HKEY_CURRENT_USER for the required registry settings, and not under HKEY_LOCAL_MACHINE. The page linked by APC gives details on how to manually copy the settings to HKEY_CURRENT_USER.
原來是win7 64位的電腦,在安裝python時,如果選擇只為當前用戶,是沒問題的,如果選擇所有用戶,那問題就是我所遇到的,ok,既然知道了這個問題,那么就好辦了,我改了一下上面的python代碼,大家可以參考附件
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的python修复不了_修复 Python version 2.6 required, which was not found in the registry.的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 建行快贷怎么提用到储蓄卡里
- 下一篇: 微信提现10万手续费多少