編程工具 占存:25.43MB 時間:2022-12-05
軟件介紹: Python是一款通用型的計算機程序設計語言,Python對編程人員來說是一款非常有利的工具,可以讓您...
下面就是Linux安裝第三方庫報錯的解決方法了,下文是該腳本的代碼,執(zhí)行腳本后再安裝第三方庫就不會出現(xiàn)錯誤代碼了。
建立一個文件 register.py 內容如下。 然后執(zhí)行該腳本
代碼如下
import sys
from _winreg import *
# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
regpath = “SOFTWAREPythonPythoncore%s” % (version)
installkey = “InstallPath”
pythonkey = “PythonPath”
pythonpath = “%s;%sLib;%sDLLs” % (
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()