Get the App
SLTechnology News&Howtos  ›  Servers  › 

Python installs mysqldb module

Shulou Source: shulou.com Published: 2022-06-02 16:42:22 09月23日 Update

mysqldb module has not been maintained for a long time, but many people are used to using mysqldb. The installation package downloaded from the official is 32 bits, while our system is 64 bits. Therefore, the installation will not find python environment variables or report the following error.

python version2.7 required,which was not found in the registry

Solution:

Create a register.py file

import sys from _winreg import * # tweak as necessaryversion = 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()

Then execute this script under doc

D:\>python egister.py

--- Python 2.7 is now registered!

Then you can happily install the mysqldb module

Download Address: https://pypi.org/project/MySQL-python/

64 bit download address: https://www.codegood.com/downloads

Tags: Module address pleasure variable official file method environment system script error will report Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MariaDB Shulou Information Shulou Technology Linux