Domanda

Like many people, I am having issues getting mysql and python to work together. My specs are:

OSX10.9.2 Anaconda 1.9.1 with python 2.7.2, although 2.5 and 2.6 appear to be included MySQL 5.6.16

I have written a python script where I try to import MySQLdb, or PyMySQL then MySQLdb, neither works.

I read many of the threads on stack overflow, and as a result I eventually tried

$ export CFLAGS=-Qunused-arguments
$ export CPPFLAGS=-Qunused-arguments
$ pip install mysql-python

The results are below. A fatal error was issued, as can be seen at the bottom of the output.

Downloading/unpacking mysql-python Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded Running setup.py (path:/private/var/folders/lx/h7jq_qx92_j0n7plsjmr6wl40000gp/T/pip_build_vincent/mysql-python/setup.py) egg_info for package mysql-python

Installing collected packages: mysql-python Running setup.py install for mysql-python building '_mysql' extension /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D_version_=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 In file included from _mysql.c:29: /Users/vincent/anaconda/include/python2.7/Python.h:33:10: fatal error: 'stdio.h' file not found #include ^ 1 error generated. error: command '/usr/bin/clang' failed with exit status 1 Complete output from command /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'))" install --record /var/folders/lx/h7jq_qx92_j0n7plsjmr6wl40000gp/T/pip-6aqGYj-record/install-record.txt --single-version-externally-managed --compile: running install

running build

running build_py

creating build

creating build/lib.macosx-10.5-x86_64-2.7

copying _mysql_exceptions.py -> build/lib.macosx-10.5-x86_64-2.7

creating build/lib.macosx-10.5-x86_64-2.7/MySQLdb

copying MySQLdb/init.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb

copying MySQLdb/converters.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb

copying MySQLdb/connections.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb

copying MySQLdb/cursors.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb

copying MySQLdb/release.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb

copying MySQLdb/times.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb

creating build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/init.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/CR.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/ER.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.5-x86_64-2.7/MySQLdb/constants

running build_ext

building '_mysql' extension

creating build/temp.macosx-10.5-x86_64-2.7

/usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D_version_=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

In file included from _mysql.c:29: /Users/vincent/anaconda/include/python2.7/Python.h:33:10: fatal error: 'stdio.h' file not found

include stdio.h

     ^

1 error generated.

error: command '/usr/bin/clang' failed with exit status 1


Cleaning up... Command /Users/vincent/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'))" install --record /var/folders/lx/h7jq_qx92_j0n7plsjmr6wl40000gp/T/pip-6aqGYj-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/lx/h7jq_qx92_j0n7plsjmr6wl40000gp/T/pip_build_vincent/mysql-python Storing debug log for failure in /Users/vincentlaufer/.pip/pip.log

I would like to thank everyone for the many answers provided that got me this far already, but also to ask if anyone knows how to solve this issue. Thank you!!

È stato utile?

Soluzione

Inclusion of the line:

$ xcode-select --install 

solves this problem, as per: GCC fatal error: stdio.h: No such file or directory

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top