繁体   English   中英

不能pip3安装mysqlclient

[英]Cannot pip3 install mysqlclient

pip3安装mysqlclient

显示以下错误,

    Collecting mysqlclient
  Using cached mysqlclient-1.3.12.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/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup_posix.py", line 54, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup_posix.py", line 54, in <listcomp>
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/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/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/

关注一些帖子并安装完毕

brew install mysql-connector-c

但仍然面临着这个问题。

对于其他解决方案尝试以下解决方案

https://stackoverflow.com/a/44338332/4107739

但找不到/ usr / local / bin / mysql / bin / mysql_config

我在MacOS上运行,对于Mysql,我安装了XAMPP。

对于mac上的python3 + mysql。 这对我有用:

  1. brew install mysql-connector-c
  2. 编辑mysql_config(找到它: which mysql_config

在mysql_config中更改以下内容:

# Create options 
libs="-L$pkglibdir"
libs="$libs -l "

至:

# Create options 
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
  1. brew info openssl

  2. 最后pip3 install mysqlclient

在XAMPP中,mysql_config将位于以下路径中的某个位置。 (根据你安装的地方)

/Applications/XAMPP/xamppfiles/bin/mysql_config

更新$ PATH以包含bin路径

export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin/

运行mysql_config, - --libs--libs_r应该有-lmysqlclient -lssl -lcrypto

 <XAMPP_PATH>mysql_config | grep libs
        --libs           [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqlclient -lssl -lcrypto]
        --libs_r         [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqlclient -lssl -lcrypto]
        --libmysqld-libs [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqld -lssl -lcrypto]

如果没有,请将mysql_config更新为以下值。

libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"

然后运行

pip3 install mysqlclient

暂无
暂无

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

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