This article mainly introduces how to solve the problem of Pythonversion2.7required and whichwasnotfoundintheregistry when installing the PIL Library. if you need a friend, you can refer to the following command to install the PIL Library: Python version 2.7 required, which was not found in the registry.
The general idea is that you cannot find the registry and search for a solution online.
Create a new register. py file and write the code:
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 = "InstallPath"
Pythonkey = "PythonPath"
Pythonpath = "% s; % s \ Lib \; % s \ DLLs \" % (
Installpath, installpath, installpath
)
Def RegisterPy ():
Try:
Reg = OpenKey (HKEY_CURRENT_USER, regpath)
Except t 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 t:
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! "
Run the following command to switch to the register. py Directory:
Reinstall PIL. the installation is successful.
If you select only the current user when installing the Python 32-bit program for Windows 7 64-bit users, the above problems will not occur. If you select all users, try the above solution.
The solution for other versions is similar.