Unable to install mysql-python using pip on macOS 10.12.4

After the error received when starting pip install mysql-python

 Collecting mysql-python Using cached MySQL-python-1.2.5.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/folders/b_/xh05hxwd0lzc3rm858jsypdc0000gn/T/pip-build-AWDYaP/mysql-python/setup.py", line 17, in <module> metadata, options = get_config() File "setup_posix.py", line 53, in get_config libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ] File "setup_posix.py", line 8, in dequote if s[0] in "\"'" and s[0] == s[-1]: IndexError: string index out of range ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/b_/xh05hxwd0lzc3rm858jsypdc0000gn/T/pip-build-AWDYaP/mysql-python/ 

I followed the instructions in this after reinstalling setuptools, and I reinstalled Python from https://www.python.org/

which -a python gives

 /Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/local/bin/python /usr/bin/python 

The error seems to have occurred since the installation of the MacOS 10.12.4 update

+6
source share
5 answers

Solved with this

 brew install mysql pip install MySQL-python 
+27
source

If you still haven’t done something like "Failed building wheel for mysql-python", try

 LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysql-python 

which works like a charm to me.

+9
source

If you are like me and installed mysql from the source in mac, then forget who offers to use brew - mysql-connector-c is already installed on your machine. If you run brew install mysql-connector-c, run brew uninstall mysql-connector-c and try installing pip mysql-python again (Python 3).

+4
source

This worked for me:

  brew install mysql@5.7 brew link --force mysql@5.7 
+2
source

This worked for me (macOS Mojave 10.14.2):

 brew install mysql@5.7 brew link --force mysql@5.7 brew install mysql-client LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysql-python 
0
source

Source: https://habr.com/ru/post/1267183/


All Articles