2014-12-21 2 views
3

mysql이 django로 작업하려고했습니다. pip를 사용하여 virtualenv에 필요한 바인딩을 설치하면 오류가 발생합니다.pip를 사용하여 패키지를 설치하는 동안 헤더 파일이 누락되었습니다.

pip install MySQL-python 

패키지가 다운로드되지만 my_config.h 헤더 파일이 없다는 오류 메시지가 나타납니다.

(django)[[email protected] pollsys]$ pip install MySQL-python 
Downloading/unpacking MySQL-python 
    Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded 
    Running setup.py (path:/home/jmathews/.virtualenvs/django/build/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 
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -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-x86_64-2.7/_mysql.o -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1 
    _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 /home/jmathews/.virtualenvs/django/bin/python -c "import setuptools, tokenize;__file__='/home/jmathews/.virtualenvs/django/build/MySQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Qa0mhq-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/jmathews/.virtualenvs/django/include/site/python2.7: 
    running install 

running build 

running build_py 

creating build 

creating build/lib.linux-x86_64-2.7 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

running build_ext 

building '_mysql' extension 

creating build/temp.linux-x86_64-2.7 

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -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-x86_64-2.7/_mysql.o -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1 

_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 

---------------------------------------- 
Cleaning up... 
Command /home/jmathews/.virtualenvs/django/bin/python -c "import setuptools, tokenize;__file__='/home/jmathews/.virtualenvs/django/build/MySQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Qa0mhq-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/jmathews/.virtualenvs/django/include/site/python2.7 failed with error code 1 in /home/jmathews/.virtualenvs/django/build/MySQL-python 
Storing debug log for failure in /home/jmathews/.pip/pip.log 

다음 패키지가 설치되고 업데이트되었습니다.

yum install -y gcc gcc-c++ libxml2-devel libxslt-devel 

는 또한 문제가 지속

yum groupinstall "Development Tools" "Development Libraries" 

을 달렸다. 패키지 또는 누락 된 종속성에 문제가 있습니까?

+4

'냠 mysql을 - devel' –

+0

Yes (예)를 설치합니다. 그것은 문제를 해결했습니다. 고맙습니다. –

답변

0

mysql 라이브러리 용 헤더 파일을 설치해야합니다. 당신의 배포본을 모르겠다. 우분투에서는 패키지 이름이 libmysqlclient-dev이다.

그런데, 새로운 프로젝트를 시작한다면 MySQL에 대한 지원이 기껏해야 불확실하기 때문에 MySQL을 통해 PostgreSQL을 추천 할 것입니다.

편집 :는 상황이 변경 밝혀 지금 bindings for Python 3

+0

예, yum 대응 항목 mysql-devel을 설치하면 문제가 해결되었습니다. 필자의 프로젝트에는 많은 읽기 작업과 PostgreSQL이 포함되어 있기 때문에 MySQL을 실행하고 있습니다. 읽기 작업으로 느려지는 것을 배웠습니다. –

+0

어디서 배웠습니까? –

1
yum info mysql-devel 

가 설치되어 있지 않다면가 지금

sudo pip install mysql-python 
0

설치 mysql-을 시도 그것을

yum install mysql-devel 

설치 dev는 내 문제도 해결했습니다. 고마워요!

-2
yum install mysql-devel 

다음

pip install MySQL-python

관련 문제