使用mariaDB库安装mysql-python时"找不到-lssl;找不到-lcrypto"

 新闻联播有没有大结局__742 发布于 2022-12-20 11:29

我正在努力在系统范围内或在安装了MariaDB 10的Ubuntu 14.04上的venv中安装mysql-python pip.还尝试使用MariaDB 5.5并获得相同的错误.我没有安装vanilla mysql-server这个问题.

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

建立必要的

蟒蛇-dev的

libmariadbclient-dev(这就是用于libmysqlclient-dev的MariaDB替代品)

蟒蛇,MySQLdb的

最初我认为这是一个安装到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

Braiam.. 41

我做了同样的事情,仍然无法重现问题:

(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提供两个库的软件包.

3 个回答
  • 我在MacOS上遇到了类似的错误,但对我来说没有"/ usr/bin/ld:找不到-lssl".

    解决了以下步骤:

    步骤1.确保已使用自制软件安装openssl.

    brew install openssl
    

    步骤2.在终端中:

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

    对于Linux,您还可以尝试yum install丢失的库并将它们添加到LIBRARY_PATH.

    2022-12-20 11:30 回答
  • 对于Debian 9.x:

    apt install libssl-dev

    2022-12-20 11:30 回答
  • 我做了同样的事情,仍然无法重现问题:

    (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提供两个库的软件包.

    2022-12-20 11:32 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有