pip MySQL-python 설치

(MySQL-python 설치에서 넘어옴)

Python MySQLdb 모듈 설치
pip MySQL-python 설치
ImportError: No module named MySQLdb

1 확인[ | ]

[root@zetawiki ~]# pip show MySQL-python
[root@zetawiki ~]# pip list | grep MySQL-python
[root@zetawiki ~]# python -c 'import MySQLdb'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named MySQLdb

2 설치 (실패)[ | ]

  • 아래와 같이 실패한다면...
(CentOS) CentOS python-devel 설치
(우분투) 우분투 python-dev 설치, 우분투 libmysqlclient-dev 설치
[root@zetawiki ~]# pip install MySQL-python
Downloading/unpacking MySQL-python
  Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
  Running setup.py egg_info for package MySQL-python
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build-root/MySQL-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found

Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip-build-root/MySQL-python/setup.py", line 17, in <module>

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 25, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-root/MySQL-python
Storing complete log in /root/.pip/pip.log

3 설치 (성공)[ | ]

[root@zetawiki ~]# pip install MySQL-python
Downloading/unpacking MySQL-python
  Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
  Running 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 -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -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.6 -c _mysql.c -o build/temp.linux-x86_64-2.6/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX
    In file included from /usr/include/mysql/my_config.h:14,
                     from _mysql.c:44:
    /usr/include/mysql/my_config_x86_64.h:1082:1: warning: "HAVE_WCSCOLL" redefined
    In file included from /usr/include/python2.6/pyconfig.h:6,
                     from /usr/include/python2.6/Python.h:8,
                     from _mysql.c:29:
    /usr/include/python2.6/pyconfig-64.h:808:1: warning: this is the location of the previous definition
    gcc -pthread -shared build/temp.linux-x86_64-2.6/_mysql.o -L/usr/lib64/mysql -L/usr/lib64 -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -lssl -lcrypto -lpython2.6 -o build/lib.linux-x86_64-2.6/_mysql.so
Successfully installed MySQL-python
Cleaning up...

4 확인 2[ | ]

[root@zetawiki ~]# python -c 'import MySQLdb'
[root@zetawiki ~]# pip list | grep MySQL-python
MySQL-python (1.2.5)
[root@zetawiki ~]# pip show MySQL-python
---
Name: MySQL-python
Version: 1.2.5
Location: /usr/lib64/python2.6/site-packages
Requires:

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}