簡體   English   中英

為什么pip install MySQL-python == 1.2.5會因C編譯錯誤而失敗?

[英]Why is pip install MySQL-python==1.2.5 failing with C compile error?

我在運行MacOS High Sierra(版本10.13.4)的Macbook上運行虛擬環境。

在虛擬環境中,我正在執行pip安裝MySQL-python。 但是它失敗並顯示如下C編譯錯誤。

此錯誤的原因是什么,如何解決?

$ pip install MySQL-python==1.2.5
Collecting MySQL-python==1.2.5
  Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Building wheels for collected packages: MySQL-python
  Running setup.py bdist_wheel for MySQL-python ... error
  Complete output from command /Users/saqib.ali/saqib_bnet_docs/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/q7/zl0gz8xj7ps8wswmxkqsf9khwzyc1z/T/pip-install-KM5pDI/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/q7/zl0gz8xj7ps8wswmxkqsf9khwzyc1z/T/pip-wheel-qP6Us6 --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.13-intel-2.7
  copying _mysql_exceptions.py -> build/lib.macosx-10.13-intel-2.7
  creating build/lib.macosx-10.13-intel-2.7/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
  copying MySQLdb/converters.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
  copying MySQLdb/connections.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
  copying MySQLdb/release.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
  copying MySQLdb/times.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
  creating build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.macosx-10.13-intel-2.7
  cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -I/usr/local/opt/openssl/include -arch i386 -arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mariadb/10.3.10/include/mysql -I/usr/local/Cellar/mariadb/10.3.10/include/mysql/.. -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.13-intel-2.7/_mysql.o
  In file included from _mysql.c:44:
  /usr/local/Cellar/mariadb/10.3.10/include/mysql/my_config.h:3:2: warning: This file should not be included by clients, include only <mysql.h> [-W#warnings]
  #warning This file should not be included by clients, include only <mysql.h>
   ^

<WARNINGS SNIPPED FOR BREVITY>

_mysql.c:2005:42: error: no member named 'reconnect' in 'struct st_mysql'
      if ( reconnect != -1 ) self->connection.reconnect = reconnect;
                             ~~~~~~~~~~~~~~~~ ^
16 warnings and 1 error generated.
error: command 'cc' failed with exit status 1

----------------------------------------
Failed building wheel for MySQL-python

為了簡潔起見,我已經刪除了一些警告。 您可以在此處看到完整的輸出。

似乎是從不兼容的mariadb安裝中提取了標頭。

您可能需要安裝mysql和/或mysqlclient

有關詳細信息,請參見: 在Mac OS X Sierra上為Django Python安裝mysqlclient

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM