Ubuntu 下的Python开发 mysqlclient安装失败问题解决,亲测有效
版本信息:
- elementaryOS 5.0 Juno (基于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 update
输入apt-get -y install mysql-server mysql-client libmysqlclient-dev mytop 然后回车开始安装, 完成后, 继
续进入虚拟django环境, 输入pip install mysqlclient 安装成功, 然后再次生成迁移, 此时迁移成功.
感谢原文博主: wylycool
博客链接: https://blog.csdn.net/wylycool/article/details/80243266
——向前走吧,往往最珍贵的东西都不容易在表层浮现的事物找到。
posted on 2018-12-21 14:41 墨书韶光(魏泯i) 阅读(1062) 评论(0) 编辑 收藏 举报