Python mac安裝mysqlclient的一個bug


 

這是一個來自mysql官方的bug,反正我是看不懂。

shuais-MBP:wxapp dandyzhang$ pipenv install mysqlclient
Installing mysqlclient...
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.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/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/mysqlclient/setup.py", line 18, in <module>
        metadata, options = get_config()
      File "/private/var/folders/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/mysqlclient/setup_posix.py", line 60, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/mysqlclient/setup_posix.py", line 60, in <listcomp>
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/mysqlclient/setup_posix.py", line 13, in dequote
        raise Exception("Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?")
    Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ? ----------------------------------------

Error:  An error occurred while installing mysqlclient!
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/mysqlclient/

This is likely caused by a bug in mysqlclient. Report this to its maintainers.

mysqlclient的作者在源碼里已經寫了個exception是專門針對這個報錯的,就是上面加粗的那一句黑色的鏈接

Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?

它說,錯誤的mysql配置,可能是鏈接里的問題。

這里就不打開鏈接了解釋了,反正就是一個官方的bug,里面也寫了怎么解決。

 

 

首先安裝mysql-connector

brew install mysql-connector-c

然后修改一下mysql_config文件,當然基於安全性的考慮需要先備份一下文件

cp /usr/local/bin/mysql_config /usr/local/bin/mysql_config.backup 

然后修改文件

sudo vim /usr/local/bin/mysql_config 

找到對應的內容位置

# Create options 
libs="-L$pkglibdir"
libs="$libs -l "
修改成
# Create options 
libs="-L$pkglibdir" libs="$libs -lmysqlclient -lssl -lcrypto"

這時候安裝mysqlclient就沒問題了。。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM