2018-12-27 Mac 安装python数据库模块 mys

2018-12-27  本文已影响8人  dongzhensong

使用pip install mysqlclient的时候出现报错:

gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.7/_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.7/_mysql.cpython-37m-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'gcc' failed with exit status 1

愣是折腾了半天,最后找到文章:https://www.jianshu.com/p/86367222dd74 以及 http://stackoverflow.com/questions/19652877/installing-saltstack-at-os-x-error-ld-library-not-found-for-lssl

在命令前加上 env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" 就可以了

(venv) AppledeiMac:pythonWeb apple$ env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient
Collecting mysqlclient
  Using cached [https://files.pythonhosted.org/packages/f7/a2/1230ebbb4b91f42ad6b646e59eb8855559817ad5505d81c1ca2b5a216040/mysqlclient-1.3.14.tar.gz](https://files.pythonhosted.org/packages/f7/a2/1230ebbb4b91f42ad6b646e59eb8855559817ad5505d81c1ca2b5a216040/mysqlclient-1.3.14.tar.gz)
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-1.3.14

搞定!

上一篇下一篇

猜你喜欢

热点阅读