What should I do if I get the error Python version 2.7 when installing third-party libraries on Linux?

Time: 2022-05-23source:Author: Neal

The following is the solution to the error when installing third-party libraries in Linux. The following is the code of the script. After executing the script and then installing the third-party libraries, the error code will not appear.

What should I do if I get the error Python version 2.7 when installing third-party libraries on Linux?

​​Create a file register.py with the following content. 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 = “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()


Related articles更多>>

Popular recommendations