错误:命令'cc'失败,在Mac上为pip安装MySQL-python退出状态为1

问题描述 投票:0回答:1

由于此导入错误,我需要在Mac上通过(pip install MySQL-python)安装MySQL-python:

ImportError:没有名为MySQLdb的模块

但是在pip安装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

我尝试了Stackoverflow提供的其他解决方案,例如:"'cc' failed with exit status 1" error when install python librarycommand 'cc' failed with exit status 1 on OSX High Sierra,但仍然出现相同的错误。有任何建议或意见来解决此问题吗?

更多信息:

 (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
python mysql installation mysql-python
1个回答
0
投票

您的Mac OS上没有安装mysql C库,有多个安装选项。

© www.soinside.com 2019 - 2024. All rights reserved.