Tag Archives: python mac install MySQLdb ModuleNotFoundError No module named ‘ConfigParser’

python mac install MySQLdb ModuleNotFoundError No module named ‘ConfigParser’

Detailed map traversal, teach you to master the complex gremlin query debugging method>>>

Problem: Error installing MySQL Python modulenotfounderror: no module named ‘configparser’

pip3 install MySQL-python

Collecting MySQL-python
  Downloading MySQL-python-1.2.5.zip (108 kB)
     |████████████████████████████████| 108 kB 91 kB/s 

    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/yp/bg6_hcgs3fj3m0_d8g9qgfl40000gn/T/pip-install-jxs0uzyh/MySQL-python/setup.py'"'"'; __file__='"'"'/private/var/folders/yp/bg6_hcgs3fj3m0_d8g9qgfl40000gn/T/pip-install-jxs0uzyh/MySQL-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/yp/bg6_hcgs3fj3m0_d8g9qgfl40000gn/T/pip-install-jxs0uzyh/MySQL-python/pip-egg-info
         cwd: /private/var/folders/yp/bg6_hcgs3fj3m0_d8g9qgfl40000gn/T/pip-install-jxs0uzyh/MySQL-python/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/yp/bg6_hcgs3fj3m0_d8g9qgfl40000gn/T/pip-install-jxs0uzyh/MySQL-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/var/folders/yp/bg6_hcgs3fj3m0_d8g9qgfl40000gn/T/pip-install-jxs0uzyh/MySQL-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Environment

    python3.7 macOS 10.15.5 

Reason:

After Python version 3. X, configparser. Py has been renamed configparser. Py, so there is an error

Solutions

cp /usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py /usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ConfigParser.py

If the above methods still can not solve the problem, cause 2:

Mysqldb has been removed from Python 3

Step 1 installation:

pip install pymysql

In the second part, the following is added to the document with the same name of the project:

import pymysql

pymysql.install_as_MySQLdb()