如何修复模块 _mysql:此 Python 的 API 版本为 1012,模块 _mysql 版本为 1013

0 投票
1 回答
1165 浏览
提问于 2025-04-16 06:48

我在使用命令行的时候遇到了一个API冲突的问题。

/home/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-linux-i686.egg-tmp/_mysql.so:6: RuntimeWarning: Python C API version mismatch for module _mysql: This Python has API version 1012, module _mysql has version 1013.

我现在使用的环境是:
Python 2.6
MySQL服务器版本:5.0.77
MySQL_python-1.2.3c1

我尝试更新MySQL-python到新版本,但没有成功。

easy_install-2.6 -d ~/lib/python2.6 MySQL-python

Searching for MySQL-python
Best match: MySQL-python 1.2.3c1
Processing MySQL_python-1.2.3c1-py2.6-linux-i686.egg
MySQL-python 1.2.3c1 is already the active version in easy-install.pth

Using /home/username/lib/python2.6/MySQL_python-1.2.3c1-py2.6-linux-i686.egg
Processing dependencies for MySQL-python
Finished processing dependencies for MySQL-python

我该如何解决这个错误呢?

1 个回答

0

这个错误信息的意思是,_mysql模块是MySQLdb的一部分,它是为比你现在使用的Python版本更新的版本构建的。API版本1013是Python 2.5和2.6使用的,而1012是Python 2.4使用的。你没有说明你是怎么使用MySQLdb的,但显然它是被Python 2.4导入的。

撰写回答