首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为python2.7安装mysql-python

问如何为python2.7安装mysql-python
EN

Stack Overflow用户
提问于 2015-01-28 14:38:54
回答 2查看 4.5K关注 0票数 3

如何为python2.7安装mysql-python。下面的脚本似乎使用了-I/usr/include/mysql,它是空的,但我还有其他文件夹,比如/usr/include/mysql51和/usr/include/mysql55,它们似乎包含头文件。

代码语言:javascript
复制
sudo pip install MYSQL-python --allow-all-external

我得到了以下错误:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

发布于 2015-01-28 20:09:24

为什么你要自己面对所有这些问题?包的维护者已经解决了这个问题。执行以下操作:

代码语言:javascript
复制
yum install MySQL-python
票数 2
EN

Stack Overflow用户

发布于 2016-06-07 03:47:44

考虑安装devel包sudo yum install mysql-devel

然后使用pip或yum:pip install mysql-python或sudo yum install MySQL-python安装mysql-python

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28186137

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档