Tag Archives: MySQL-python Install Error

How to Solve MySQL-python Install Error:Python version 2.7 required, which was not found in the registry

1. install MySQL-python-1.2.3.win-amd64-py2.7.exe, when prompted: Python version 2.7 required, which was not found in the registry

This is in the registry can not identify python2.7, the reason windows is 64-bit, the installation of Python is 32-bit

Note: MySQLdb for python (32/64 bit) download; http://www.codegood.com/archives/129; different versions are available, choose the py you need

The solution is:
1. Create a new register.py file in any disk folder
Copy the following code into it:

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

2. Locate the directory where the file is located and run python register.py

3. If you run MySQLdb, it will be automatically recognized and installed successfully