我在Ubuntu 14.04上安装mysql-python pip(不论是系统范围内还是在虚拟环境中),并且已经安装了MariaDB 10,但尝试使用MariaDB 5.5也出现了相同的错误。如果只安装原版的mysql-server则不会出现此问题。
我已使用apt-get安装了以下内容:
- build-essential
- python-dev
- libmariadbclient-dev(该库取代了libmysqlclient-dev)
- python-mysqldb
最初我认为这个问题是在虚拟环境中安装时出现的,但后来发现mysql-python无法在系统范围内安装。以下是我在虚拟环境中安装所使用的命令。
virtualenv venv
. venv/bin/activate
pip install mysql-python==1.2.5
In file included from _mysql.c:44:0:
/usr/include/mysql/my_config.h:439:0: warning: "HAVE_WCSCOLL" redefined [enabled by default]
#define HAVE_WCSCOLL
^
In file included from /usr/include/python2.7/pyconfig.h:3:0,
from /usr/include/python2.7/Python.h:8,
from _mysql.c:29:
/usr/include/x86_64-linux-gnu/python2.7/pyconfig.h:911:0: note: this is the location of the previous definition
#define HAVE_WCSCOLL 1
^x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmariadbclient_r -lpthread -lz -lm -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /root/env/bin/python -c "import setuptools, tokenize;__file__='/root/env/build/mysql- python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-EyhO2v-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/env/include/site/python2.7 failed with error code 1 in /root/env/build/mysql-python
Storing debug log for failure in /root/.pip/pip.log
yum install openssl-devel
命令,然后执行pip install MySQL-python
即可解决问题。 - chiralelibssl-dev
软件包,而安装openssl
软件包(被认为是libssl
的Mac等效版本)也没有任何帮助。 - saran3h