【问题标题】:Mac OS Sierra virtualenv (python 2.7) pip install mysqlclient errorMac OS Sierra virtualenv (python 2.7) pip install mysqlclient 错误
【发布时间】:2017-03-13 21:55:20
【问题描述】:

在 Mac OS Sierra 上,使用 python2.7 创建了 virtualenv,并尝试安装 mysqlclient 以使用带有 MySQL 的 Django。我通过自制软件安装了 MySQL 5.6。运行“pip install mysqlclient”会出现以下错误:

Running setup.py bdist_wheel for mysqlclient ... error
...
 13 warnings generated.
  cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql56/5.6.32/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-intel-2.7/_mysql.so
  ld: library not found for -lssl
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'cc' failed with exit status 1

  Failed building wheel for mysqlclient
Command "...env2.7/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-xVuIu1-record/install-record.txt --single-version-externally-managed --compile --install-headers .../env2.7/include/site/python2.7/mysqlclient" failed with error code 1 in /private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/

任何帮助将不胜感激。

【问题讨论】:

    标签: mysql python-2.7 pip homebrew macos-sierra


    【解决方案1】:

    答案是使用以下方式安装开发工具:

    xcode-select --install

    【讨论】:

    • 也为我工作。我仍在使用 OS X El Capitan,但出现了相同的错误消息。
    【解决方案2】:

    就我而言,我需要执行两个步骤:

    xcode-select --install
    

    正如@howevilweare 所说,并且还使用 env 命令使用 brew 安装的 openssl 进行 pip 安装:

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

    【讨论】:

    • 据我所知,这是使用 Homebrew 的 openSSL 在 macOS Sierra 上运行的唯一方法。
    猜你喜欢
    • 2016-05-13
    • 1970-01-01
    • 2014-04-17
    • 2011-06-24
    • 2017-09-22
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    相关资源
    最近更新 更多