无法在ubuntu 12.04下安装MySQL-python

时间:2015-01-24 19:46:28

标签: python mysql ubuntu-12.04 virtualenv mysql-python

我试图在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

但它没有帮助。

2 个答案:

答案 0 :(得分:0)

问题是libmysqlclient.so没有https://github.com/javer/gentoo-overlay/issues/4#issuecomment-30748799中描述的符号链接

答案 1 :(得分:0)

对于我在Centos上,问题是MySQL-python没有提供libmysqlclient_r.so但它有其他编号的版本。通过卸载它并安装Percona-SQL-devel,python能够正确地找到库和构建轮。