杭州网站建设招聘网,wordpress有小方块,新媒体营销策略有哪些,wordpress 图片标签异常是关于mysqlclient和PyMySQL的
这个异常有些老生常谈了#xff0c;但是至今都是一个问题#xff0c;尤其是Python3在不同系统上的兼容性相差较大。这次记录的版本是Python3.10#xff08;Python3.11#xff09;#xff0c;在Windows11系统版本上可以直接安装mysqlcli…异常是关于mysqlclient和PyMySQL的
这个异常有些老生常谈了但是至今都是一个问题尤其是Python3在不同系统上的兼容性相差较大。这次记录的版本是Python3.10Python3.11在Windows11系统版本上可以直接安装mysqlclient
我印象已经有很长一段时间可以在Django中使用PyMySQL替代mysqlclient并且这些年mysqlclient有各种依赖问题导致安装失败相反PyMySQL则可以直接安装。
但是目前发现最新的Django5Python3.11版本在Windows上正常安装mysqlclient了且使用PyMySQL则导致一些不兼容的安装问题。而ubuntu22.04容器中的同版本Python就出现了下面的报错
Collecting mysqlclient2.2.4Using cached https://pypi.tuna.tsinghua.edu.cn/packages/79/33/996dc0ba3f03e2399adc91a7de1f61cb14b57ebdb4cc6eca8a78723043cb/mysqlclient-2.2.4.tar.gz (90 kB)Installing build dependencies ... doneGetting requirements to build wheel ... errorerror: subprocess-exited-with-error× Getting requirements to build wheel did not run successfully.│ exit code: 1╰─ [27 lines of output]/bin/sh: 1: pkg-config: not found/bin/sh: 1: pkg-config: not found/bin/sh: 1: pkg-config: not foundTrying pkg-config --exists mysqlclientCommand pkg-config --exists mysqlclient returned non-zero exit status 127.Trying pkg-config --exists mariadbCommand pkg-config --exists mariadb returned non-zero exit status 127.Trying pkg-config --exists libmariadbCommand pkg-config --exists libmariadb returned non-zero exit status 127.Traceback (most recent call last):File /home/env/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py, line 363, in modulemain()File /home/env/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/env/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-wrm_4di5/overlay/lib/python3.10/site-packages/setuptools/build_meta.py, line 325, in get_requires_for_build_wheelreturn self._get_build_requires(config_settings, requirements[wheel])File /tmp/pip-build-env-wrm_4di5/overlay/lib/python3.10/site-packages/setuptools/build_meta.py, line 295, in _get_build_requiresself.run_setup()File /tmp/pip-build-env-wrm_4di5/overlay/lib/python3.10/site-packages/setuptools/build_meta.py, line 311, in run_setupexec(code, locals())File string, line 155, in moduleFile string, line 49, in get_config_posixFile string, line 28, 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× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─ See above for output.note: This error originates from a subprocess, and is likely not a problem with pip.依据异常提示这个错误提示是由于缺少 pkg-config 工具导致的。pkg-config 是一个帮助定位编译器和链接器标志的工具某些 Python 包需要它来定位依赖库的位置。
这里推荐先后安装以下两个包
apt install pkg-config另外安装mysql-client时libmysqlclient-dev 是 MySQL 客户端库的开发包通常用于构建需要连接到 MySQL 的软件。在大多数情况下需要构建 Python 的 MySQL 客户端库如 mysqlclient您需要安装 libmysqlclient-dev。
apt install libmysqlclient-dev