简体   繁体   English

在MacOS Sierra(Python 3.6)上安装mysqlclient时出错

[英]Error while installing mysqlclient on MacOS Sierra (Python 3.6)

I'm trying to install mysqlclient for my MacOS Sierra (Python3). 我正在尝试为MacOS Sierra(Python3)安装mysqlclient。

Well, I tried to follow instructions on official page https://github.com/PyMySQL/mysqlclient-python . 好吧,我尝试按照官方页面https://github.com/PyMySQL/mysqlclient-python上的说明进行操作。

So, everything was good until: 因此,一切都很好,直到:

pip install mysqlclient
pip3 install mysqlclient

It throws me next things: 它给我带来了接下来的事情:

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/q4/j199zrpj015c7dyj7qfl22qm0000gn/T/pip-build-9v6DOo/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/q4/j199zrpj015c7dyj7qfl22qm0000gn/T/pip-build-9v6DOo/mysqlclient/

If anyone has some ideas to fix it, help me please. 如果有人有解决办法,请帮助我。 (Libraries was downloaded with brew). (库是与brew一起下载的)。 I have suspicion on having both Python 2.7 and Python 3.6 on my mac. 我怀疑Mac上同时装有python 2.7和python 3.6。 But, actually I don't know :) 但是,实际上我不知道:)

EDIT: Spent hours of search, still couldn't find an answer 编辑:花了几个小时的搜索,仍然找不到答案

https://stackoverflow.com/a/43645248/7136153 this helps me. https://stackoverflow.com/a/43645248/7136153这对我有帮助。 I do following: 我做以下事情:

brew uninstall mysql-connector-c
brew install mysql
pip3 install mysqlclient

Your pip is old. 你的点子很旧。 First upgrade it and then try. 首先升级它,然后尝试。

pip3 install -U pip
sudo pip3 install mysqlclient

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM