700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 解决pip3 install mysqlclinet 报错 OSError: mysql_config not found

解决pip3 install mysqlclinet 报错 OSError: mysql_config not found

时间:2019-01-29 20:48:38

相关推荐

解决pip3 install mysqlclinet 报错 OSError: mysql_config not found

作者:Bright Xu

这里用的服务器是Ubuntu18.04,CentOS服务器 请参考 CentOS 解决pip安装mysqlclient报错的问题

Django开发项目时使用MySQL数据库,然而部署到Ubuntu服务器的时候会经常出错。

Django连接MySQL数据库需要依赖第三方库mysqlclient,然而服务器通过pip3 install mysqlclient命令安装第三方库mysqlclient时会经常报错:

ERROR: Command errored out with exit status 1:command: /home/bright/web/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ffv9cnlj/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ffv9cnlj/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-ffv9cnlj/mysqlclient/pip-egg-infocwd: /tmp/pip-install-ffv9cnlj/mysqlclient/Complete output (12 lines):/bin/sh: 1: mysql_config: not found/bin/sh: 1: mariadb_config: not found/bin/sh: 1: mysql_config: not foundTraceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-ffv9cnlj/mysqlclient/setup.py", line 16, in <module>metadata, options = get_config()File "/tmp/pip-install-ffv9cnlj/mysqlclient/setup_posix.py", line 61, in get_configlibs = mysql_config("libs")File "/tmp/pip-install-ffv9cnlj/mysqlclient/setup_posix.py", line 29, in mysql_configraise EnvironmentError("%s not found" % (_mysql_config_path,))OSError: mysql_config not found----------------------------------------ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

apt安装的 mysql 的 mysql_config 文件缺失了,或者说系统里没有mysql_config文件,,,,

解决方案:

sudo apt install libmysqlclient-dev

然后再:

pip3 install mysqlclient

发现:

Building wheels for collected packages: mysqlclientBuilding wheel for mysqlclient (setup.py) ... doneCreated wheel for mysqlclient: filename=mysqlclient-1.4.6-cp37-cp37m-linux_x86_64.whl size=100352 sha256=07ec9df2d857581eee041a6ae7740149919a265d19776c7eb8dbce47b4108324Stored in directory: /home/bright/.cache/pip/wheels/42/b3/81/881eb2e7c762ba99ec0349eeb2b8b03760871295b5800d7a51Successfully built mysqlclientInstalling collected packages: mysqlclientSuccessfully installed mysqlclient-1.4.6

mysqlclient安装成功。

这样即使服务器里没有安装MySQL数据库,也不会报错。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。