在 Mac OS X Sierra 上为 Django Python 安装 mysqlclient

新手上路,请多包涵

我已经安装了

  • 蟒蛇 2.7.13
  • 姜戈 1.11
  • MySQL 5.7.17

我想将 MySQL 与 Django 一起使用,但是在安装 mysql 连接器之后,我尝试在 $ pip install mysqlclient 上为 Python 安装 mysqlclient,但我遇到了这个问题:

 Collecting mysqlclient
  Using cached mysqlclient-1.3.10.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/y_/c31n_1v12v169zfv829p_v_80000gn/T/pip-build-f51KhW/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 54, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "setup_posix.py", line 12, in dequote
        if s[0] in "\"'" and s[0] == s[-1]:
    IndexError: string index out of range

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/y_/c31n_1v12v169zfv829p_v_80000gn/T/pip-build-f51KhW/mysqlclient/

原文由 Андрей Морченко 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 369
1 个回答

我需要以下内容来构建/安装 mysqlclient

 brew install mysql-client
# mysql-client is not on the `PATH` by default
export PATH="/usr/local/opt/mysql-client/bin:$PATH"
# openssl is not on the link path by default
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"

然后我可以 pip wheel mysqlclient / pip install mysqlclient 成功

原文由 anthony sottile 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题