明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

Linux安裝第三方庫(kù)時(shí)報(bào)錯(cuò)Python version 2.7怎么辦?

[摘要]Linux系統(tǒng)用戶(hù)在安裝第三方庫(kù)的時(shí)候,突然提示錯(cuò)誤代碼Python version 2.7 required,which was not found in the registry,遇到這個(gè)問(wèn)題的...

  Linux系統(tǒng)用戶(hù)在安裝第三方庫(kù)的時(shí)候,突然提示錯(cuò)誤代碼Python version 2.7 required,which was not found in the registry,遇到這個(gè)問(wèn)題的時(shí)候你只需建立一個(gè)腳本并執(zhí)行,即可解決這個(gè)問(wèn)題。

Linux安裝第三方庫(kù)時(shí)報(bào)錯(cuò)Python version 2.7怎么辦?

  建立一個(gè)文件 register.py 內(nèi)容如下。 然后執(zhí)行該腳本

  代碼如下

  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_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()

  上面就是Linux安裝第三方庫(kù)報(bào)錯(cuò)的解決方法了,上文就是該腳本的代碼,執(zhí)行腳本后再安裝第三方庫(kù)就不會(huì)出現(xiàn)錯(cuò)誤代碼了。


Linux是一套免費(fèi)使用和自由傳播的類(lèi)Unix操作系統(tǒng)