Linux安装第三方库时报错Python version 2.7怎么办?

时间:2022-05-23来源:作者:Neal

      下面就是Linux安装第三方库报错的解决方法了,下文是该脚本的代码,执行脚本后再安装第三方库就不会出现错误代码了。

Linux安装第三方库时报错Python version 2.7怎么办?

      建立一个文件 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()


相关文章更多>>

热门推荐