python - 错误:命令 'cc' 在 Mac 上为 pip install MySQL-python 退出状态为 1 失败
问题描述
由于此导入错误,我需要在 Mac 上通过 (pip install MySQL-python) 安装 MySQL-python:
ImportError:没有名为 MySQLdb 的模块
但是在 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
我尝试了 Stackoverflow 提供的不同解决方案,例如: 在 OSX High Sierra 上安装 python 库或 命令 'cc' 失败,退出状态为 1 时出现“'cc' failed with exit status 1”错误,但仍然出现相同的错误。有什么建议或意见来解决这个问题吗?
更多信息:
(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
解决方案
您没有在 Mac OS 上安装 mysql C 库,有多种安装选项。
您可以在 Mac OS 上轻松安装它brew
,或者使用 google 搜索其他选项以使用您的环境安装库。
更多信息
推荐阅读
- python-3.x - What exceptions can be raised by `load_kube_config`?
- javascript - Postman Accesstoken 自动刷新问题
- visual-studio - Visual Studio 2017:在路径中找不到和或未创建 Exe
- css - 设计材料表以匹配设计
- reactjs - 使用反应将鼠标悬停在框上时如何显示按钮?
- google-bigquery - 无法使用从存储文件传输来更新大查询表
- cron - Pi Cron 作业无法运行
- excel - 在功能区中添加自定义选项卡
- java - 无法在 iText 核心 java 中生成报告
- mongodb - 如何在 Robo 3T (Robomongo) 中导出连接