mac 安裝 python mysqlclient 遇到的問題及解決方案

來源:互聯網
上載者:User

標籤:last   pkg   rac   color   遇到的問題   實驗   library   directory   aries   

在 mac 上安裝 mysqlclient 遇到了一些問題,尋找資料很多人都遇到了同樣的問題。通過資料和實驗,成功了。這裡記錄一下,希望幫到遇到同樣問題的人。

本人使用python3, 安裝步驟如下:

brew install mysql-connector-cpip3 install mysqlclient

當執行 pip3 install mysqlclient 是出現錯誤:

? /usr/local/Cellar/mysql-connector-c/6.1.11/bin >pip3 install mysqlclientCollecting 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/2w/56bgkvqd1xldl56fx_gx_fg00000gn/T/pip-build-f9admsgv/mysqlclient/setup.py", line 17, in <module>        metadata, options = get_config()      File "/private/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000gn/T/pip-build-f9admsgv/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/2w/56bgkvqd1xldl56fx_gx_fg00000gn/T/pip-build-f9admsgv/mysqlclient/setup_posix.py", line 54, in <listcomp>        libraries = [dequote(i[2:]) for i in libs if i.startswith(‘-l‘)]      File "/private/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000gn/T/pip-build-f9admsgv/mysqlclient/setup_posix.py", line 12, in dequote        if s[0] in "\"‘" and s[0] == s[-1]:    IndexError: string index out of range    ----------------------------------------

解決方案:mysql_config

執行:vim mysql_config,搜尋 libs,或者114行,替換為115行即可

112 # Create options113 libs="-L$pkglibdir"114 #libs="$libs -l "   ##原始碼115 libs="$libs -lmysqlclient -lssl -lcrypto "  ##修改成這樣

再次執行pip3 install mysqlclient,成功了。如下所示:

? /usr/local/Cellar/mysql-connector-c/6.1.11/bin >pip3 install mysqlclientCollecting mysqlclient  Using cached mysqlclient-1.3.12.tar.gzBuilding wheels for collected packages: mysqlclient  Running setup.py bdist_wheel for mysqlclient ... done  Stored in directory: /Users/kk/Library/Caches/pip/wheels/df/bb/60/bf7c315cbe163515db1c846e4ffa5557dd785c82e82f3492e8Successfully built mysqlclientInstalling collected packages: mysqlclientSuccessfully installed mysqlclient-1.3.12

 

mac 安裝 python mysqlclient 遇到的問題及解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.