问题描述
像许多人一样,我在让mysql和python一起工作时遇到问题。 我的规格是:
OSX10.9.2 Anaconda 1.9.1和python 2.7.2,尽管似乎包括了2.5和2.6 MySQL 5.6.16
我写了一个python脚本,尝试导入MySQLdb或PyMySQL,然后导入MySQLdb,但都无效。
我读了堆栈溢出的许多线程,结果我最终尝试了
$ export CFLAGS=-Qunused-arguments
$ export CPPFLAGS=-Qunused-arguments
$ pip install mysql-python
结果如下。 发出致命错误,如在输出底部所示。
下载/解压缩mysql-python下载MySQL-python-1.2.5.zip(108kB):已下载108kB正在运行setup.py(路径:/ private / var / folders / lx / h7jq_qx92_j0n7plsjmr6wl40000gp / T / pip_build_vincent / mysql-python / setup。 py)软件包mysql-python的egg_info
安装收集的软件包:mysql-python为mysql-python运行setup.py安装,以构建_mysql'扩展名/ usr / bin / clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments- Dversion_info =(1,2,5,'final',1)-D_ 版本 _ = 1.2.5 -I / usr / local / mysql / include -I / Users / vincentlaufer / anaconda / include / python2.7 -c _mysql .c -o build / temp.macosx-10.5-x86_64-2.7 / _mysql.o -Os -g -fno-strict-aliasing -arch x86_64在_mysql.c中包含的文件中:29:/ Users / vincent / anaconda / include /python2.7/Python.h:33:10:致命错误:找不到'stdio.h'文件#include ^ 1错误生成。 错误:命令'/ usr / bin / clang'失败,退出状态为1,从命令/ Users / vincentlaufer / anaconda / bin / python -c“ import setuptools,tokenize; file ='/ private / var / folders / lx / h7jq_qx92_j0n7plsjmr6wl40000gp / T / pip_build_vincent / mysql-python / setup.py'; exec(compile(getattr(tokenize,'open',open)( file ).read()。replace('\\ r \\ n','\\ n' ), file ,'exec'))“安装--record /var/folders/lx/h7jq_qx92_j0n7plsjmr6wl40000gp/T/pip-6aqGYj-record/install-record.txt --single-version-externally-managed --compile:running安装
运行构建
运行build_py
创建版本
创建build / lib.macosx-10.5-x86_64-2.7
复制_mysql_exceptions.py-> build / lib.macosx-10.5-x86_64-2.7
创建build / lib.macosx-10.5-x86_64-2.7 / MySQLdb
复制MySQLdb / init .py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb
复制MySQLdb / converters.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb
复制MySQLdb / connections.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb
复制MySQLdb / cursors.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb
复制MySQLdb / release.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb
复制MySQLdb / times.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb
创建build / lib.macosx-10.5-x86_64-2.7 / MySQLdb / constants
复制MySQLdb / constants / init .py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb / constants
复制MySQLdb / constants / CR.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb / constants
复制MySQLdb / constants / FIELD_TYPE.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb / constants
复制MySQLdb / constants / ER.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb / constants
复制MySQLdb / constants / FLAG.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb / constants
复制MySQLdb / constants / REFRESH.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb / constants
复制MySQLdb / constants / CLIENT.py-> build / lib.macosx-10.5-x86_64-2.7 / MySQLdb / constants
运行build_ext
建立'_mysql'扩展
创建build / temp.macosx-10.5-x86_64-2.7
/ usr / bin / clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict原型-Qunused-arguments -Qunused-arguments -Dversion_info =(1,2,5,'final',1)-D_ 版本 _ = 1.2 .5 -I / usr / local / mysql / include -I / Users / vincent / anaconda / include / python2.7 -c _mysql.c -o build / temp.macosx-10.5-x86_64-2.7 / _mysql.o -Os -g -fno-strict-aliasing -arch x86_64
在_mysql.c:29包含的文件中:/Users/vincent/anaconda/include/python2.7/Python.h:33:10:致命错误:找不到'stdio.h'文件
包括stdio.h
^
产生1个错误。
错误:命令“ / usr / bin / clang”失败,退出状态为1
清理...命令/ Users / vincent / anaconda / bin / python -c“导入setuptools,标记化; 文件 ='/ private / var / folders / lx / h7jq_qx92_j0n7plsjmr6wl40000gp / T / pip_build_vincent / mysql-python / setup.py' ; exec(compile(getattr(tokenize,'open',open)( file ).read()。replace('\\ r \\ n','\\ n'), file ,'exec'))“ install --record /var/folders/lx/h7jq_qx92_j0n7plsjmr6wl40000gp/T/pip-6aqGYj-record/install-record.txt --single-version-externally-managed --compile失败,错误代码为/ private / var / folders / lx / h7jq_qxpl2jj0n / T / pip_build_vincent / mysql-python在/Users/vincentlaufer/.pip/pip.log中存储调试日志以查找失败
我要感谢大家提供的许多答案,这些答案已经使我走到了这一步,而且还要询问是否有人知道如何解决此问题。 谢谢!!
1楼
包含行:
$ xcode-select --install
解决此问题的方法如下: