pip3 install mysqlclient在windows上没问题,但是在linux上出现问题

本文详细介绍了在Linux环境下解决Python与MySQL数据库连接问题的方法。首先,确保安装了必要的库,包括libmysqlclient-dev、libssl-dev和libcrypto++-dev。然后,通过pip3安装mysqlclient库,完成数据库连接的配置。

1.一般是因为linux需要安装一些数据库支持

2.先保证安装一下的东西

sudo apt-get install libmysqlclient-dev

sudo apt install libssl-dev

sudo apt install libcrypto++-dev

3.然后再去安装mysqlclient

pip3 install mysqlclient 

 就没问题了

(django) [root@iZ7vhr6bkd1v9kZ django]# pip3 install mysqlclient Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/ Collecting mysqlclient Using cached http://mirrors.cloud.aliyuncs.com/pypi/packages/61/68/810093cb579daae426794bbd9d88aa830fae296e85172d18cb0f0e5dd4bc/mysqlclient-2.2.7.tar.gz (91 kB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [26 lines of output] Trying pkg-config --exists mysqlclient Command &#39;pkg-config --exists mysqlclient&#39; returned non-zero exit status 1. Trying pkg-config --exists mariadb Command &#39;pkg-config --exists mariadb&#39; returned non-zero exit status 1. Trying pkg-config --exists libmariadb Command &#39;pkg-config --exists libmariadb&#39; returned non-zero exit status 1. Trying pkg-config --exists perconaserverclient Command &#39;pkg-config --exists perconaserverclient&#39; returned non-zero exit status 1. Traceback (most recent call last): File "/root/.virtualenvs/django/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module> main() File "/root/.virtualenvs/django/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main json_out["return_val"] = hook(**hook_input["kwargs"]) File "/root/.virtualenvs/django/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel return hook(config_settings) File "/tmp/pip-build-env-8y3hrfjx/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=[]) File "/tmp/pip-build-env-8y3hrfjx/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 303, in _get_build_requires self.run_setup() File "/tmp/pip-build-env-8y3hrfjx/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 319, in run_setup exec(code, locals()) File "<string>", line 156, in <module> File "<string>", line 49, in get_config_posix File "<string>", line 28, in find_package_name Exception: 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.
03-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值