MySQLdb/_mysql.c:1340:5: note: use option -std=c99 or -std=gnu99 to compile your code
阿新 • • 發佈:2020-12-31
技術標籤:python+django開發網站
解決方案:
手動下載,更改出錯的程式碼,手動安裝
解決步驟:
- 查詢python下安裝模組的資料夾site-packages,檢視到多個資料夾,通過檢視之前安裝的模組確定安裝位置
[[email protected] Python-3.7.4]# find / -name site-packages
/home/python/Python-3.7.4/Lib/site-packages
/usr/local/python3/lib/python3.7/site-packages
[[email protected] Python-3.7.4]# ls /usr/local/lib/python3.7/site-packages colorlog easy_install.py pip-20.3.1.dist-info __pycache__
- 使用wget下載mysqlclient的安裝包,地址:https://pypi.org/project/mysqlclient/2.0.2/#files
[[email protected] site-packages]# wget https://files.pythonhosted.org/packages/0e/68/f79de0e0fcdb041783124b825771e0ba6a3d0893b7b4c4735f130e42af47/mysqlclient-2.0.2.tar.gz --2020-12-15 17:56:38-- https://files.pythonhosted.org/packages/0e/68/f79de0e0fcdb041783124b825771e0ba6a3d0893b7b4c4735f130e42af47/mysqlclient-2.0.2.tar.gz 正在解析主機 files.pythonhosted.org (files.pythonhosted.org)... 151.101.109.63, 2a04:4e42:36::319 正在連線 files.pythonhosted.org (files.pythonhosted.org)|151.101.109.63|:443... 已連線。 已發出 HTTP 請求,正在等待迴應... 200 OK 長度:88293 (86K) [application/x-tar] 正在儲存至: “mysqlclient-2.0.2.tar.gz” 100%[=================================================================================================================================================>] 88,293 372KB/s 用時 0.2s 2020-12-15 17:56:39 (372 KB/s) - 已儲存 “mysqlclient-2.0.2.tar.gz” [88293/88293])
- 解壓
[[email protected] site-packages]# tar -xvf mysqlclient-2.0.2.tar.gz
[[email protected] Python-3.7.4]# cd mysqlclient-2.0.2/MySQLdb/
vi _mysql.c
- 在vi介面中,輸入1340n,直達第1340行,原for (unsigned int i=0; i<n; i++)修改如下,先宣告,後呼叫,儲存退出
- 進入mysqlclient-2.0.2目錄,安裝
[[email protected] mysqlclient-2.0.2]# python setup.py install
- 完成
解決方案二:
嘗試降低mysqlclient的版本,即可安裝成功。
pip3 install mysqlclient==2.0.1