简体   繁体   中英

Unable to install MySQLdb on Python 2.7 on MacOS Mojave

I used to create a big program in Python 2.7 that uses MySQLdb a long time ago. I developed it both on Mac OS and PC. I just had to re-refomat my Mac and I'm now on Mojave. Whereas I have been able in the past to easily install MySQLdb, I'm unable to do so now.

I've tried all that was available on the forums with no success. PIP, easy-install, Brew and many other solutions that I forgot. Even "easy_install MySQL-python" found in Installing MySQLDB on Python 2.7.3 under CentOS gave me an error ending by : EnvironmentError: mysql_config not found

I expect to be able to "import MySQLdb" in my Python code, but MySQLdb isn't installed and so "no found"

Thanks a lot for your help.

So, you either have upgrade your MySQL Version to a 64Bit Version, get the newest MySQL-Python Connector, update your code and use this instead of MySQLdb. Which is the safest and best solution, but u have to put in some work (no problem if your code isn't that long anyways...)

https://dev.mysql.com/downloads/connector/python/

https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html

import mysql.connector

Second chance is, staying with your old 32Bit MySQL Version (for Example 5.6.20 32Bit), and still using the same old MySQL Python Connector (For Example Mysql-Python Connector 1.2.3 in 32Bit, found on the Mysql Download page aswell) you used before. There will be some popup errors, such as a few Libraries are out of date and probably not compatible anymore, but it's working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM