ubuntu 12.04下无法安装MySQL-python
Posted
技术标签:
【中文标题】ubuntu 12.04下无法安装MySQL-python【英文标题】:Unable to install MySQL-python under ubuntu 12.04 【发布时间】:2015-03-23 15:36:05 【问题描述】:我正在尝试在 virtualenv 环境下的 ubuntu 12.04 中安装 mysql-python 模块,但意外遇到以下错误:
building '_mysql' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
In file included from /usr/include/mysql/mysql.h:64:0,
from _mysql.c:46:
/usr/include/mysql/mysql/client_plugin.h:97:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
In file included from /usr/include/mysql/mysql.h:64:0,
from _mysql.c:46:
/usr/include/mysql/mysql/client_plugin.h:107:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
-Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu
-lmysqlclient_r -lpthread -lz -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
我已经跑了:
sudo apt-get install mysql-server mysql-client python-mysqldb libmysqlclient-dev python-dev
但它没有帮助。
【问题讨论】:
【参考方案1】:问题是 libmysqlclient.so 没有https://github.com/javer/gentoo-overlay/issues/4#issuecomment-30748799 中描述的符号链接
【讨论】:
【参考方案2】:对于 Centos 上的我来说,问题是 MySQL-python 没有提供 libmysqlclient_r.so,但它有其他编号的版本。通过卸载它并安装 Percona-SQL-devel,python 能够正确找到库并构建***。
【讨论】:
其实问题出在 MySQL-devel,而不是 MySQL-python。以上是关于ubuntu 12.04下无法安装MySQL-python的主要内容,如果未能解决你的问题,请参考以下文章
昨天在VM下安装Ubuntu 12.04 ,安装完成后,提示正在自动安装mtools,无法进入桌面系统
Ubuntu12.04 终端下提示输入密码,无法输入 怎么办
Ubuntu12.04 终端下提示输入密码,无法输入 怎么办