Ubuntu 下的Python開發 mysqlclient安裝失敗問題解決,親測有效
阿新 • • 發佈:2018-12-21
版本資訊:
- elementoryOS 5 (基於Ubuntu18)
- Python3.6
遇到的問題:
在虛擬環境中安裝mysqlclient, pip install mysqlclient
出現了以下錯誤:
Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/f7/a2/1230ebbb4b91f42ad6b646e59eb8855559817ad5505d81c1ca2b5a216040/mysqlclient-1.3.14.tar.gz Complete output from command python setup.py egg_info: /bin/sh: 1: mysql_config: not found Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-nm6pcvjm/mysqlclient/setup.py", line 16, in <module> metadata, options = get_config() File "/tmp/pip-install-nm6pcvjm/mysqlclient/setup_posix.py", line 53, in get_config libs = mysql_config("libs_r") File "/tmp/pip-install-nm6pcvjm/mysqlclient/setup_posix.py", line 28, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) OSError: mysql_config not found ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-nm6pcvjm/mysqlclient/
解決辦法:
切出虛擬環境, 進入ubuntu的root賬戶, 輸入apt-get -y install mysql-server mysql-client libmysqlclient-dev mytop 然後回車開始安裝, 完成後, 繼
續進入虛擬django環境, 輸入pip install mysqlclient 安裝成功, 然後再次生成遷移, 此時遷移成功.
感謝原文博主: wylycool
部落格連結: https://blog.csdn.net/wylycool/article/details/80243266