2015-01-28 13 views
7

Wie installiere ich mysql-python für python2.7. Das folgende Skript scheint -I/usr/include/mysql zu verwenden, das leer ist, aber ich habe andere Ordner wie/usr/include/mysql51 und/usr/include/mysql55, die Headerdateien zu enthalten scheinen.Wie installiere ich mysql-python für python2.7

sudo pip install MYSQL-python --allow-all-external 

Ich habe folgende Fehlermeldung:

Collecting MYSQL-python 
    Using cached MySQL-python-1.2.5.zip 
Installing collected packages: MYSQL-python 
    Running setup.py install for MYSQL-python 
    building '_mysql' extension 
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=pentium4 -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=pentium4 -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-i686-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX 
    _mysql.c:44:23: fatal error: my_config.h: No such file or directory 
    #include "my_config.h" 
         ^
    compilation terminated. 
    error: command 'gcc' failed with exit status 1 
    Complete output from command /usr/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-vXN9gu/MYSQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-dKaHt3-record/install-record.txt --single-version-externally-managed --compile: 
    running install 

    running build 

    running build_py 

    creating build 

    creating build/lib.linux-i686-2.7 

    copying _mysql_exceptions.py -> build/lib.linux-i686-2.7 

    creating build/lib.linux-i686-2.7/MySQLdb 

    copying MySQLdb/__init__.py -> build/lib.linux-i686-2.7/MySQLdb 

    copying MySQLdb/converters.py -> build/lib.linux-i686-2.7/MySQLdb 

    copying MySQLdb/connections.py -> build/lib.linux-i686-2.7/MySQLdb 

    copying MySQLdb/cursors.py -> build/lib.linux-i686-2.7/MySQLdb 

    copying MySQLdb/release.py -> build/lib.linux-i686-2.7/MySQLdb 

    copying MySQLdb/times.py -> build/lib.linux-i686-2.7/MySQLdb 

    creating build/lib.linux-i686-2.7/MySQLdb/constants 

    copying MySQLdb/constants/__init__.py -> build/lib.linux-i686-2.7/MySQLdb/constants 

    copying MySQLdb/constants/CR.py -> build/lib.linux-i686-2.7/MySQLdb/constants 

    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-i686-2.7/MySQLdb/constants 

    copying MySQLdb/constants/ER.py -> build/lib.linux-i686-2.7/MySQLdb/constants 

    copying MySQLdb/constants/FLAG.py -> build/lib.linux-i686-2.7/MySQLdb/constants 

    copying MySQLdb/constants/REFRESH.py -> build/lib.linux-i686-2.7/MySQLdb/constants 

    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-i686-2.7/MySQLdb/constants 

    running build_ext 

    building '_mysql' extension 

    creating build/temp.linux-i686-2.7 

    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=pentium4 -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=pentium4 -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-i686-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX 

    _mysql.c:44:23: fatal error: my_config.h: No such file or directory 

    #include "my_config.h" 

         ^

    compilation terminated. 

    error: command 'gcc' failed with exit status 1 

    ---------------------------------------- 
    Command "/usr/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-vXN9gu/MYSQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-dKaHt3-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-vXN9gu/MYSQL-python 
+0

Haben Sie installiert mysql? mysql-python benötigt python-dev (möglicherweise python-devel auf centos/redhat) und libmysqlclient-dev (plus gcc usw. und mysql-server, wenn Sie den Server auf demselben PC ausführen). Welche MySQL-Version? – lxx

+0

@Ixx Danke! Wir haben bereits alle oben genannten Funktionen installiert. – brisk

+0

Welche MySQL-Version? und haben Sie alle Entwicklerwerkzeuge und Bibliotheken installiert? sudo yum groupinstall "Entwicklungstools" – lxx

Antwort

1

Warum Sie sich all diese Probleme stellen wollte? Dies wurde bereits von Paketbetreuern gelöst. Sie:

yum install MySQL-python 
0

Betrachten Entwickler-Paket sudo yum install mysql-devel

Dann mysql-Python mit pip oder yum install Installation: erste pip install mysql-pythonORsudo yum install MySQL-python