I'm trying to get to a MySql database through python, starting with a centos ec2 instance with python upgraded to 2.7 from 2.6. It's not working because my gcc compiler cannot find a the python header file. which python
returns /usr/bin/python
, and which gcc
returns /usr/bin/gcc
.
The following is what I've tried.
Thanks to a comment by @romuloigor, the discussion in chat/comments at this question and this question for the missing file Python.h
, my method is the following:
sudo yum install mysql mysql-devel mysql-libs
sudo yum install python-devel
sudo yum install MySQL-python
sudo pip install mysql-python
I think if you've upgraded your python (say, from 2.6 to 2.7) this won't yet work. You need to put the path of the Python.h
header file searchable by gcc
(see this question and this other one) by doing the following after python-devel
is installed but before pip installing mysql-python
:
find / -name Python.h 2>/dev/null # find path
Mine was at /usr/include/python2.6/Python.h
:
C_INCLUDE_PATH=/usr/include/python2.6
sudo su
export C_INCLUDE_PATH
exit
echo $C_INCLUDE_PATH # should look right
Note, you can't use the gcc -I
option because we can't access the c source file gcc is compiling because it's a pip install, and all the files are temporary.
Now, this still doesn't work. How would you tell gcc to find the header file?
PS. I think this question should be on stackoverflow because the FAQ states "Software development tools" and SO suggested the tags; please feel free to correct if you think differently!