安裝python時MySQLdb報錯的問題描述及解決方法
問題描述:
windows安裝python mysqldb時報錯python version 2.7 required,which was not found in the registry
網(wǎng)上很多方案,比如方案一:
Python3.x時, from _winreg import *
改為 from winreg import *
去掉下劃線
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()
方案二:
這種也是我遇到的情況,是因為你的MySQLdb與python的版本不匹配,你要下載匹配的版本即可
總結(jié)
以上所述是小編給大家介紹的安裝python時MySQLdb報錯的問題描述及解決方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
詳解Python如何批量采集京東商品數(shù)據(jù)流程
這不快過年了,又是要買年貨,又是要給女朋友買禮物的,分析一下價格,看看哪些是真的降價了2022-01-01python中join與os.path.join()函數(shù)實例詳解
os.path.join()函數(shù)用于路徑拼接文件路徑,下面這篇文章主要給大家介紹了關(guān)于python中join與os.path.join()函數(shù)的相關(guān)資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2022-03-03python實現(xiàn)的解析crontab配置文件代碼
這篇文章主要介紹了python實現(xiàn)的解析crontab配置文件代碼,也可以說是python版的crontab,代碼中包含大量注釋,需要的朋友可以參考下2014-06-06Python結(jié)合MySQL數(shù)據(jù)庫編寫簡單信息管理系統(tǒng)完整實例
最近Python課堂上布置了綜合實訓(xùn),實驗?zāi)繕耸窃O(shè)計一個信息管理系統(tǒng),下面這篇文章主要給大家介紹了關(guān)于Python結(jié)合MySQL數(shù)據(jù)庫編寫簡單信息管理系統(tǒng)的相關(guān)資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2023-06-06