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)

1 문제 상황[ | ]

[root@zetawiki test]# pwd
/root/test
[root@zetawiki test]# cat db_connection_test.py 
import MySQLdb
... (생략)
[root@zetawiki test]# python db_connection_test.py 
Traceback (most recent call last):
  File "db_connection_test.py", line 1, in <module>
    import MySQLdb
  File "/root/test/MySQLdb/__init__.py", line 23, in <module>
    (version_info, _mysql.version_info))
ImportError: this is MySQLdb version (1, 2, 3, 'gamma', 1), but _mysql is version (1, 2, 4, 'beta', 4)
→ Import 에러 발생: 이 MySQLdb 버전은 1.2.3.gamma.1인데, _mysql의 버전은 1.2.4.beta.4임

2 확인[ | ]

[root@zetawiki test]# grep -n version /root/test/MySQLdb/__init__.py
11:For information on how MySQLdb handles type conversion, see the
17:from release import __version__, version_info, __author__
21:if version_info != _mysql.version_info:
22:    raise ImportError("this is MySQLdb version %s, but _mysql is version %r" %
23:                      (version_info, _mysql.version_info))
94:    'paramstyle', 'string_literal', 'threadsafety', 'version_info']
[root@zetawiki test]# grep -n version /root/test/MySQLdb/release.py
3:version_info = (1,2,3,'gamma',1)
4:__version__ = "1.2.3c1"
[root@zetawiki test]# pip list | grep MySQL
MySQL-python (1.2.4b4)
→ 이미 설치된 모듈(1.2.4b4)이 있는데, 하위폴더 MySQLdb에 다른 버전의 모듈(1.2.3c1)이 있어서 발생하는 문제

3 해결방법[ | ]

  • 하위폴더를 삭제하면 된다.
혹시 나중에 필요할 수도 있으니 폴더명을 바꾸어놓자.
[root@zetawiki test]# mv MySQLdb MySQLdb_20140708
[root@zetawiki test]# python db_connection_test.py 
[root@zetawiki test]#
→ 이제 아무 이상이 없다.

4 같이 보기[ | ]

5 참고[ | ]

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