CentOS 6.5, Python 2.7에서 mysqlclient 설치하기

mysqlclientMySQLdb를 개선한 것으로, Python 3도 지원한다.

윈도우 7, Python 2.7에서는 ‘pip install mysqlclinet’ 명령어로 쉽게 설치된다. 그러나 CentOS 6.5에서는 아래와 같은 순서로 설치를 해야 한다.

[USER@PLUTO bin]$ Sudo yum install pythondevel mysqldevel
(catnap) [USER@PLUTO bin]$ python pip install mysqlclient
cs

참고

– https://github.com/PyMySQL/mysqlclient-python

주의할 점

CentOS에 python-devel, mysql-devel가 없을 때 설치하면 아래와 같은 에러가 발생한다.

(catnap) [USER@PLUTO bin]$ python pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient1.3.7.tar.gz
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient … error
  Complete output from command /opt/Python27/catnap/bin/python “import setuptools, tokenize;__file__=’/tmp/pip-build-40FgWg/mysqlclient/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(__file__).read().replace(‘rn’, ‘n’), __file__, ‘exec’))” bdist_wheel /tmp/tmpXTAm3Ipipwheel pythontag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linuxx86_642.7
  copying _mysql_exceptions.py > build/lib.linuxx86_642.7
  creating build/lib.linuxx86_642.7/MySQLdb
  copying MySQLdb/__init__.py > build/lib.linuxx86_642.7/MySQLdb
  copying MySQLdb/compat.py > build/lib.linuxx86_642.7/MySQLdb
  copying MySQLdb/converters.py > build/lib.linuxx86_642.7/MySQLdb
  copying MySQLdb/connections.py > build/lib.linuxx86_642.7/MySQLdb
  copying MySQLdb/cursors.py > build/lib.linuxx86_642.7/MySQLdb
  copying MySQLdb/release.py > build/lib.linuxx86_642.7/MySQLdb
  copying MySQLdb/times.py > build/lib.linuxx86_642.7/MySQLdb
  creating build/lib.linuxx86_642.7/MySQLdb/constants
  copying MySQLdb/constants/__init__.py > build/lib.linuxx86_642.7/MySQLdb/constants
  copying MySQLdb/constants/CR.py > build/lib.linuxx86_642.7/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py > build/lib.linuxx86_642.7/MySQLdb/constants
  copying MySQLdb/constants/ER.py > build/lib.linuxx86_642.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py > build/lib.linuxx86_642.7/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py > build/lib.linuxx86_642.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py > build/lib.linuxx86_642.7/MySQLdb/constants
  running build_ext
  building ‘_mysql’ extension
  creating build/temp.linuxx86_642.7
  gcc pthread fnostrictaliasing O2 DNDEBUG fwrapv O3 Wall Wstrictprototypes fPIC Dversion_info=(1,3,7,‘final’,1D__version__=1.3.7 I/usr/include/mysql I/usr/local/include/python2.7 c _mysql.c o build/temp.linuxx86_642.7/_mysql.o pipe Wp,D_FORTIFY_SOURCE=2 fexceptions fstackprotector param=sspbuffersize=4 m64 D_GNU_SOURCE D_FILE_OFFSET_BITS=64 D_LARGEFILE_SOURCE fnostrictaliasing fwrapv fPIC DUNIV_LINUX DUNIV_LINUX
  _mysql.c:29:23: error: my_config.h: 그런 파일이나 디렉터리가 없습니다
  _mysql.c:30:19: error: mysql.h: 그런 파일이나 디렉터리가 없습니다
  _mysql.c:31:26: error: mysqld_error.h: 그런 파일이나 디렉터리가 없습니다
  _mysql.c:51:20: error: errmsg.h: 그런 파일이나 디렉터리가 없습니다
  _mysql.c:74: error: expected specifierqualifierlist before ‘MYSQL’
  _mysql.c:88: error: expected specifierqualifierlist before ‘MYSQL_RES’
  _mysql.c: In function ‘_mysql_Exception’:
  _mysql.c:129: warning: implicit declaration of function ‘mysql_errno’
(생략)
    _mysql.c:2297: error: ‘_mysql_ResultObject’ has no member named ‘result’
    _mysql.c:2298: error: ‘_mysql_ResultObject’ has no member named ‘result’
    _mysql.c: In function ‘_mysql_ResultObject_dealloc’:
    _mysql.c:2306: warning: implicit declaration of function ‘mysql_free_result’
    _mysql.c:2306: error: ‘_mysql_ResultObject’ has no member named ‘result’
    _mysql.c: At top level:
    _mysql.c:2563: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
    _mysql.c:2570: error: ‘_mysql_ConnectionObject’ has no member named ‘converter’
    _mysql.c:2577: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
    _mysql.c:2584: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
    _mysql.c:2592: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
    _mysql.c:2654: error: ‘_mysql_ResultObject’ has no member named ‘converter’
    _mysql.c:2654: error: initializer element is not constant
    _mysql.c:2654: error: (near initialization for ‘_mysql_ResultObject_memberlist[0].offset’)
    _mysql.c:2661: error: ‘_mysql_ResultObject’ has no member named ‘has_next’
    _mysql.c:2661: error: initializer element is not constant
    _mysql.c:2661: error: (near initialization for ‘_mysql_ResultObject_memberlist[1].offset’)
    _mysql.c: In function ‘_mysql_ConnectionObject_getattro’:
    _mysql.c:2680: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
    error: command ‘gcc’ failed with exit status 1
    
Command “/opt/Python27/catnap/bin/python -u -c “import setuptools, tokenize;__file__=‘/tmp/pip-build-40FgWg/mysqlclient/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(__file__).read().replace(‘rn’‘n’), __file__, ‘exec’))” install –record /tmp/pip-T_qtXx-record/install-record.txt –single-version-externally-managed –compile –install-headers /opt/Python27/catnap/include/site/python2.7/mysqlclient” failed with error code 1 in /tmp/pipbuild40FgWg/mysqlclient/
(catnap) [USER@PLUTO bin]$
cs

댓글 달기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

위로 스크롤