python安裝mysqlclient
python在使用pip安裝mysqlclient的時候報錯超時或者平臺不支援,我通過手動安裝解決問題,以下方法僅供參考
一. 檢視當前系統平臺支援的whl檔案
儲存以下程式碼為.py檔案並儲存執行
import pip._internal
item=pip._internal.pep425tags.get_supported()
for i in item:
print(i)
以我的windows為例:
看到有cp37,cp37m,win32所以應該下載 mysqlclient‑1.4.6‑cp37‑cp37m‑win32.whl 並安裝,安裝成功
www.lfd.uci.edu/~gohlke/pythonlibs...
C:\Users\rexle>pip install C:\Users\rexle\mysqlclient-1.4.2-cp37-cp37m-win32.whl
Processing c:\users\rexle\mysqlclient\mysqlclient-1.4.2-cp37-cp37m-win32.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.2
You are using pip version 19.0.3, however version 20.3.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
二. Linux安裝mysqlclient
linux平臺檢視支援的whl檔案與windows一樣:
可以發現上面的那個下載連結並沒有cp36,cp36m,linux_x86_64之類的whl檔案
這時可以下載mysqlclient‑1.4.6‑cp36‑cp36m‑win_amd64.whl 並改名為 mysqlclient‑1.4.6‑cp36‑cp36m‑linux_x86_64.whl
並使用pip安裝即可。
[root@jojo mysqlclient]# cp mysqlclient-1.4.2-cp36-cp36m-win_amd64.whl mysqlclient-1.4.2-cp36-cp36m-linux_x86_64.whl
[root@jojo mysqlclient]# /usr/local/python3/bin/pip3.6 install mysqlclient-1.4.2-cp36-cp36m-linux_x86_64.whl
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Processing ./mysqlclient-1.4.2-cp36-cp36m-linux_x86_64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.2
WARNING: You are using pip version 19.1.1, however version 20.3.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
至此安裝完畢。
本作品採用《CC 協議》,轉載必須註明作者和本文連結