首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >安装mysql-python时“找不到-lssl;找不到-lcrypto”?

安装mysql-python时“找不到-lssl;找不到-lcrypto”?
EN

Stack Overflow用户
提问于 2014-09-23 01:09:14
回答 4查看 34.6K关注 0票数 38

我正在努力安装mysql-python pip,无论是在系统范围内还是在安装了MariaDB 10的ubuntu14.04上的venv中。我也尝试了MariaDB 5.5,并得到了相同的错误。在安装了vanilla mysql-server的情况下,我没有这个问题。

我已经通过apt-get安装了以下内容:

  • build-essential
  • python-dev
  • libmariadbclient-dev (这是libmysqlclient-dev)
  • python-mysqldb

的MariaDB替代品

最初,我认为将其安装到venv中是一个问题,但后来我注意到mysql-python也不能在系统范围内安装。下面是我在venv中安装的cmds。

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
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2014-09-23 01:42:24

您需要安装OpenSSL的开发库。它可以是libssl-dev、libssl-devel,如果您的发行版为dev库提供了单独的包。或者安装完整的openssl包。

(venv)➜  src  pip install mysql-python==1.2.5
Downloading/unpacking mysql-python==1.2.5
  Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
  Running setup.py (path:/home/braiam/src/venv/build/mysql-python/setup.py) egg_info for package mysql-python
    
Installing collected packages: mysql-python
  Running setup.py install for mysql-python
    building '_mysql' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -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 -DBIG_JOINS=1 -fno-strict-aliasing -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing
    In file included from _mysql.c:44:0:
    /usr/include/mysql/my_config.h:439:0: warning: "HAVE_WCSCOLL" redefined
     #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,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -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
    
Successfully installed mysql-python
Cleaning up...

但是,你有两个我没有的信息,那就是:

/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto

如果您使用ld -lcrypto --verboseld -lssl --verbose,则不会产生以下结果:

➜  src  ld -lcrypto --verbose | grep succeeded
attempt to open //usr/lib/x86_64-linux-gnu/libcrypto.so succeeded
ld: warning: cannot find entry symbol _start; not setting start address
➜  src  ld -lssl --verbose | grep succeeded
attempt to open //usr/lib/x86_64-linux-gnu/libssl.so succeeded
ld: warning: cannot find entry symbol _start; not setting start address

因此,要解决这个问题,只需确保您已经安装了提供这两个库的libssl-dev包。

票数 51
EN

Stack Overflow用户

发布于 2017-04-21 17:25:52

我在MacOS上遇到了类似的错误,但没有提示"/usr/bin/ld: cannot find -lssl“。

求解步骤如下:

步骤1.确保您已经安装了带有自制软件的openssl。

brew install openssl

步骤2.在终端中:

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

对于Linux,您还可以尝试yum install您缺少的库,并将它们添加到LIBRARY_PATH。

票数 16
EN

Stack Overflow用户

发布于 2018-11-20 20:22:34

对于Debian 9.x:

apt install libssl-dev

票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25979525

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档