当前位置: 首页 > 面试题库 >

OSX ld:找不到用于-lssl的库

蒋弘致
2023-03-14
问题内容

我正在尝试使用python 3在OSX high sierra上的virtrualenv中安装mysqlclient,并得到以下错误:

  Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient, coverage, django-coverage-plugin, Pygments, babel, alabaster, sphinxcontrib-websupport, imagesize, pyparsing, packaging, snowballstemmer, MarkupSafe, Jinja2, docutils, Sphinx, typing, django-extensions, Werkzeug, django-test-plus, text-unidecode, python-dateutil, Faker, factory-boy, sqlparse, django-debug-toolbar, decorator, simplegeneric, wcwidth, prompt-toolkit, appnope, pickleshare, ptyprocess, pexpect, ipython-genutils, traitlets, parso, jedi, ipython, ipdb, py, pluggy, attrs, pytest, pytest-django, termcolor, pytest-sugar
  Running setup.py install for mysqlclient ... error
    Complete output from command /private/var/virtualenvs/todobackend/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/80/lb0c7r0s5bj3rfrvv1pp85g80000gn/T/pip-build-sqswyq3d/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/80/lb0c7r0s5bj3rfrvv1pp85g80000gn/T/pip-g8z3z8q5-record/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/virtualenvs/todobackend/bin/../include/site/python3.6/mysqlclient:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.13-x86_64-3.6
    copying _mysql_exceptions.py -> build/lib.macosx-10.13-x86_64-3.6
    creating build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/compat.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb
    creating build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.13-x86_64-3.6/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.13-x86_64-3.6
    clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/local/Cellar/mysql/5.7.10/include/mysql -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.13-x86_64-3.6/_mysql.o -fno-omit-frame-pointer
    In file included from _mysql.c:29:
    In file included from /usr/local/Cellar/mysql/5.7.10/include/mysql/mysql.h:64:
    /usr/local/Cellar/mysql/5.7.10/include/mysql/mysql/client_plugin.h:97:3: warning: this function declaration is not a prototype [-Wstrict-prototypes]
      MYSQL_CLIENT_PLUGIN_HEADER
      ^
    /usr/local/Cellar/mysql/5.7.10/include/mysql/mysql/client_plugin.h:92:16: note: expanded from macro 'MYSQL_CLIENT_PLUGIN_HEADER'
      int (*deinit)();                                      \
                   ^
    /usr/local/Cellar/mysql/5.7.10/include/mysql/mysql/client_plugin.h:107:3: warning: this function declaration is not a prototype [-Wstrict-prototypes]
      MYSQL_CLIENT_PLUGIN_HEADER
      ^
    /usr/local/Cellar/mysql/5.7.10/include/mysql/mysql/client_plugin.h:92:16: note: expanded from macro 'MYSQL_CLIENT_PLUGIN_HEADER'
      int (*deinit)();                                      \
                   ^
    2 warnings generated.
    clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -Qunused-arguments -Qunused-arguments build/temp.macosx-10.13-x86_64-3.6/_mysql.o -L/usr/local/Cellar/mysql/5.7.10/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.13-x86_64-3.6/_mysql.cpython-36m-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'clang' failed with exit status 1

    ----------------------------------------
Command "/private/var/virtualenvs/todobackend/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/80/lb0c7r0s5bj3rfrvv1pp85g80000gn/T/pip-build-sqswyq3d/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/80/lb0c7r0s5bj3rfrvv1pp85g80000gn/T/pip-g8z3z8q5-record/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/virtualenvs/todobackend/bin/../include/site/python3.6/mysqlclient" failed with error code 1 in /private/var/folders/80/lb0c7r0s5bj3rfrvv1pp85g80000gn/T/pip-build-sqswyq3d/mysqlclient/

尝试过xcode-select --install但没有用。我已经在同一台计算机上安装了mysql服务器。


问题答案:

升级到osx Mojave和python 3.7.2后,我遇到了同样的问题。这对我有用:

# Required for mysqlclient, see brew info openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"

pip3 install mysqlclient

希望能帮助到你。有关更多信息,请参见此处。



 类似资料:
  • 问题内容: 我在MacOS上运行mysql@8.x版本,我已经用brew安装了mysql和mysql-connector-o。目前与mysql的brew链接。 在我的python3虚拟环境中运行Django项目时,我收到以下错误- 并在使用pip安装mysqlclient时,出现以下错误 问题答案: 正如jordanm所指出的,问题恰恰与缺少的openssl库有关,为此,我按照以下步骤修复了我的问

  • 我奔跑 我得到了一组输出,看起来像: 最后它说: 运行easy_install或从源代码处安装都会在最后给我带来相同的错误(关于-lssl找不到库的部分)。 运行brew安装(或升级)openssl会产生以下结果 有人能帮我吗?

  • 问题内容: 我有一堂课,看起来像下面这样: 我的hibernate映射文件按如下所示映射属性: 我收到以下错误: 看来hibernate不喜欢我的大写字母。我该如何解决? 问题答案: 应该管用…

  • 我对java“I get this error”不熟悉,找不到适合getText(String)方法JTextComponent的方法。getText(int,int)不适用(实际参数列表和形式参数列表长度不同)方法JTextComponent。getText()不适用 (Alt Enter显示提示)“当我试图运行我的程序时。请帮助。我做错了什么?

  • 我想允许用户上传两个图像,封面和徽标。然后将它们保存在fi恢复中。我在行中出错 找不到适用于into(Uri)方法RequestCreator的方法。into(目标)不适用(参数不匹配;Uri无法转换为目标)方法RequestCreator。into(ImageView)不适用(参数不匹配;Uri无法转换为ImageView)

  • 我在为python安装regex模块时遇到了麻烦,希望得到任何建议和帮助。当我在Windows系统上使用“pip install”时,会出现以下错误: 在@inc<@inc contains:c:/perl64/site/lib c:/perl64/lib。)C:\patha\pathb\perl\bin/pip第5行找不到pip.pm。BEGIN失败--编译在C:\patha\pathb\per