簡體   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