"Pip MySQL-python 설치"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-<source +<syntaxhighlight , -</source> +</syntaxhighlight>))
 
(사용자 3명의 중간 판 31개는 보이지 않습니다)
1번째 줄: 1번째 줄:
;MySQL-python 설치
{{소문자}}
;Python MySQLdb 모듈 설치
;pip MySQL-python 설치
;<nowiki>ImportError: No module named MySQLdb</nowiki>


==방법==
==확인==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
[root@zetawiki ~]# pip show MySQL-python
... (생략)
[root@zetawiki ~]# pip list | grep MySQL-python
2014-07-07 10:44:57 (375 KB/s) - “MySQL-python-1.2.3.tar.gz” saved [70305/70305]
[root@zetawiki ~]# python -c 'import MySQLdb'
</source>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named MySQLdb
</syntaxhighlight>
 
==설치 (실패)==
{{참고|Command "python setup.py egg info" failed with error code 1 in}}
* 아래와 같이 실패한다면...
:(CentOS) [[CentOS python-devel 설치]]
:(우분투) [[우분투 python-dev 설치]], [[우분투 libmysqlclient-dev 설치]]
<syntaxhighlight lang='console'>
[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
</syntaxhighlight>
 
==설치 (성공)==
<syntaxhighlight lang='console'>
[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...
</syntaxhighlight>
 
==확인 2==
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c 'import MySQLdb'
[root@zetawiki ~]# pip list | grep MySQL-python
MySQL-python (1.2.5)
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# pip show MySQL-python
---
Name: MySQL-python
Version: 1.2.5
Location: /usr/lib64/python2.6/site-packages
Requires:
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[MySQL]]
* [[mysqlclient]] ★★★
*[[Python]]
*[[CentOS python-devel 설치]]
*[[우분투 python-dev 설치]]
*[[우분투 libmysqlclient-dev 설치]]
*[[리눅스 flask 설치]]
*[[리눅스 flask 설치]]
*[[Python 모듈 설치 확인]]
*[[Python 모듈 설치 확인]]
*[[this is MySQLdb version (1, 2, 3, 'gamma', 1), but _mysql is version (1, 2, 3, 'final', 0)]]
*[[this is MySQLdb version (1, 2, 3, 'gamma', 1), but _mysql is version (1, 2, 3, 'final', 0)]]
*[[MySQL]]
*[[Python]]


[[분류: 설치]]
[[분류: pip install]]
[[분류: ImportError]]
[[분류: legacy]]
[[분류: import MySQLdb]]

2020년 12월 27일 (일) 13:15 기준 최신판

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 }}