美文网首页
Macos安装报错 ld: library not found

Macos安装报错 ld: library not found

作者: 醋溜八酱 | 来源:发表于2019-05-15 19:00 被阅读0次

    Macos安装报错 ld: library not found for -lssl


    首先,我通过:

    pip install mysqlclient==1.3.13
    

    然后报错

    /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    running install
    running bdist_egg
    running egg_info
    creating mysqlclient.egg-info
    writing mysqlclient.egg-info/PKG-INFO
    writing dependency_links to mysqlclient.egg-info/dependency_links.txt
    writing top-level names to mysqlclient.egg-info/top_level.txt
    writing manifest file 'mysqlclient.egg-info/SOURCES.txt'
    reading manifest file 'mysqlclient.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'mysqlclient.egg-info/SOURCES.txt'
    installing library code to build/bdist.macosx-10.9-x86_64/egg
    running install_lib
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.6
    copying _mysql_exceptions.py -> build/lib.macosx-10.9-x86_64-3.6
    creating build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    creating build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.9-x86_64-3.6
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/usr/local/opt/zlib/include -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/local/Cellar/mysql-connector-c/6.1.11/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.9-x86_64-3.6/_mysql.o
    gcc -bundle -undefined dynamic_lookup -arch x86_64 -g -L/usr/local/opt/zlib/lib -I/usr/local/opt/zlib/include build/temp.macosx-10.9-x86_64-3.6/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.6/_mysql.cpython-36m-darwin.so
    ld: library not found for -lssl
    

    其中,主要报错:

    ld: library not found for -lssl
    

    原因分析:

    安装过程中,无法找到openssl文件

    由于苹果公司已经放弃openssl加密转而使用自家的加密方式,导致mac上面是没有oepnssl的,所以需要

    # 安装openssl
    brew install openssl
    # 如果已经安装
    brew upgrade openssl
    # 如果还不行
    xcode-select --install
    

    如果还不行(例如我),那么直接在pip的时候链接brew的openssl,记得用上不使用缓存模式

    env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip --no-cache install mysqlclient==1.3.13
    

    ok!

    结果如下:

     env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip --no-cache install mysqlclient==1.3.13
    Collecting mysqlclient==1.3.13
      Downloading https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz (90kB)
        100% |████████████████████████████████| 92kB 105kB/s 
    Installing collected packages: mysqlclient
      Running setup.py install for mysqlclient ... done
    Successfully installed mysqlclient-1.3.13
    

    相关文章

      网友评论

          本文标题:Macos安装报错 ld: library not found

          本文链接:https://www.haomeiwen.com/subject/mjmmaqtx.html