简体   繁体   中英

error: command 'cc' failed with exit status 1 on Mac for pip install MySQL-python

I need to install MySQL-python through (pip install MySQL-python) on Mac due to this import error:

ImportError: No module named MySQLdb

But there is this error during pip install MySQL-python:

running build_ext
building '_mysql' extension
creating build/temp.macosx-10.14-intel-2.7
cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes 
-Qunused-arguments -Qunused-arguments -arch i386 
-arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) 
-D__version__=1.2.5 -I/usr/local/opt/mysql-client/include/mysql 
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
-c _mysql.c -o build/temp.macosx-10.14-intel-2.7/_mysql.o
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
         ^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1

I tried different solutions provided by Stackoverflow such as: "'cc' failed with exit status 1" error when install python library or command 'cc' failed with exit status 1 on OSX High Sierra but still getting the same error. Any suggestions or comments to resolve this?

Further info:

 (virt-env) m-c0:fz$ which python
   /usr/bin/python
 (virt-env) m-c0:fz$ which pip
  /usr/local/bin/pip
 (virt-env) m-c0:fz$ python --version
  Python 2.7.16

  export PATH="/usr/local/opt/cython/bin:$PATH"
  export PATH="/Users/zf/Library/Python/2.7/bin:$PATH"
  export PATH=$PATH:/usr/local/Cellar/mysql/8.0.18_1/bin
  export PATH="/usr/local/opt/mysql-client/bin:$PATH"
  export CFLAGS=-Qunused-arguments
  export CPPFLAGS=-Qunused-arguments

You don't have mysql C libraries installed on your Mac OS, there are multiple options to install it.

You can install it easy fi you have brew installed on your Mac OS, or google for other options to install the libs using your env.

More info

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