Python 开发篇——添加 mysqlclient
发布于: 48 分钟前
最近使用 mysql8.0,于是我就尝试用 Django 的框架。但是执行poetry add mysqlclient
却出现了错误:
(python3.7) dison@dison-X450LD:~/workstation/project/script_scheduler$ poetry add mysqlclient
Using version ^2.0.3 for mysqlclient
Updating dependencies
Resolving dependencies... (0.1s)
Package operations: 1 install, 0 updates, 0 removals
• Installing mysqlclient (2.0.3): Failed
EnvCommandError
Command ['/home/dison/miniconda3/envs/python3.7/bin/pip', 'install', '--no-deps', 'file:///home/dison/.cache/pypoetry/artifacts/62/65/91/bcefed4d522a6f6269f2052d15faa4291b24d11c2b8722ef54c370b813/mysqlclient-2.0.3.tar.gz'] errored with the following return code 1, and output:
Processing /home/dison/.cache/pypoetry/artifacts/62/65/91/bcefed4d522a6f6269f2052d15faa4291b24d11c2b8722ef54c370b813/mysqlclient-2.0.3.tar.gz
ERROR: Command errored out with exit status 1:
command: /home/dison/miniconda3/envs/python3.7/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-8vtznvan/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-8vtznvan/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-pip-egg-info-fbnd90o_
cwd: /tmp/pip-req-build-8vtznvan/
Complete output (15 lines):
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
mysql_config --version
mariadb_config --version
mysql_config --libs
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-8vtznvan/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-req-build-8vtznvan/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/tmp/pip-req-build-8vtznvan/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
----------------------------------------
WARNING: Discarding file:///home/dison/.cache/pypoetry/artifacts/62/65/91/bcefed4d522a6f6269f2052d15faa4291b24d11c2b8722ef54c370b813/mysqlclient-2.0.3.tar.gz. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
at ~/.poetry/lib/poetry/utils/env.py:1101 in _run
1097│ output = subprocess.check_output(
1098│ cmd, stderr=subprocess.STDOUT, **kwargs
1099│ )
1100│ except CalledProcessError as e:
→ 1101│ raise EnvCommandError(e, input=input_)
1102│
1103│ return decode(output)
1104│
1105│ def execute(self, bin, *args, **kwargs):
复制代码
仔细检查是我通过 docker 部署 mysql 并没有提供 mysql 的开发环境。这里我就执行了sudo apt-get install libmysqlclient-dev
(我电脑返厂维修了,只能先用 ubuntu20.04 的旧笔电凑合一下)安装好后就可以正常添加mysqlclient
(python3.7) dison@dison-X450LD:~/workstation/project/script_scheduler$ poetry add mysqlclient
Using version ^2.0.3 for mysqlclient
Updating dependencies
Resolving dependencies... (0.2s)
Package operations: 1 install, 0 updates, 0 removals
复制代码
参考:
划线
评论
复制
发布于: 48 分钟前阅读数: 3
版权声明: 本文为 InfoQ 作者【DisonTangor】的原创文章。
原文链接:【http://xie.infoq.cn/article/0998bd7c4bcf0e45df395e103】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
DisonTangor
关注
怀揣一个武侠梦的男孩 2020.07.29 加入
还未添加个人简介
评论