找软件用软件,就到华军软件园! 软件发布
所在位置: 首页 — 教程攻略 — 教程 — 电脑软件教程  —  Linux安装...

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

作者:Neal 日期:2022-05-23

Python
Python-3.11.102.0 for Windows

编程工具 占存:52.8MB 时间:2022-01-18

软件介绍: Python是一款通用型的计算机程序设计语言,Python对编程人员来说是一款非常有利的工具,可以让您...

立即查看

      下面就是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()


相关文章