Linux installation third-party library error Python version 2.7 how to do?

  

Linux system users when installing third-party libraries, suddenly prompted the error code Python version 2.7 required, which was not found in the registry, encountered this problem You can solve this problem by simply creating a script and executing it.

Create a file register.py follows. Then execute the script

The code is as follows

import sys

from _winreg import *

# tweak as necessary

version = sys. Version[:3]

installpath = sys.prefix

regpath = “SOFTWARE\\Python\\Pythoncore\\%s\\” % (version)

installkey = &ldquoquo ;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:

p Rint “*** 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()

The above is the solution for the Linux installation of third-party libraries, the above is the script The code, after executing the script and then installing the third-party library, will not appear error code.

Copyright © Windows knowledge All Rights Reserved