今天docker内搭建python3.10环境时报这个错误,安装 mysqlclient 时报错。
WARNING: The directory '/home/seluser/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Collecting mysqlclientDownloading mysqlclient-2.2.0.tar.gz (89 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.5/89.5 KB 114.5 kB/s eta 0:00:00Installing build dependencies ... doneGetting requirements to build wheel ... errorerror: subprocess-exited-with-error× Getting requirements to build wheel did not run successfully.│ exit code: 1╰─> [22 lines of output]Trying pkg-config --exists mysqlclientCommand 'pkg-config --exists mysqlclient' returned non-zero exit status 1.Trying pkg-config --exists mariadbCommand 'pkg-config --exists mariadb' returned non-zero exit status 1.Traceback (most recent call last):File "/home/seluser/.pyenv/versions/3.10.3/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>main()File "/home/seluser/.pyenv/versions/3.10.3/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in mainjson_out['return_val'] = hook(**hook_input['kwargs'])File "/home/seluser/.pyenv/versions/3.10.3/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheelreturn hook(config_settings)File "/tmp/pip-build-env-wke_e7h4/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheelreturn self._get_build_requires(config_settings, requirements=['wheel'])File "/tmp/pip-build-env-wke_e7h4/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in _get_build_requiresself.run_setup()File "/tmp/pip-build-env-wke_e7h4/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in run_setupexec(code, locals())File "<string>", line 154, in <module>File "<string>", line 48, in get_config_posixFile "<string>", line 27, in find_package_nameException: Can not find valid pkg-config name.Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
找了半天找不到为什么,
最后网上搜索到一个命令:
apt-get install libmysqlclient-dev
先安装了这个后,再安装就没问题了。
话说docker安装python环境是真的扯淡