编程工具 占存:25.43MB 时间:2022-12-05
软件介绍: Python是一款通用型的计算机程序设计语言,Python对编程人员来说是一款非常有利的工具,可以让您...
下面就是Linux安装第三方库报错的解决方法了,下文是该脚本的代码,执行脚本后再安装第三方库就不会出现错误代码了。
建立一个文件 register.py 内容如下。 然后执行该脚本
代码如下
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()