CentOS7中安装mysqlclient
# 出现报错
[root@iZbp11gpxfapiize7sb6ixZ /]# pip3 install mysqlclient==2.1.0
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Requirement already satisfied: mysqlclient==2.1.0 in /backend/venv/lib/python3.10/site-packages (2.1.0)
[notice] A new release of pip is available: 24.1 -> 25.0.1
[notice] To update, run: pip install --upgrade pip
(venv) [root@iZbp11gpxfapiize7sb6ixZ /]#
连接断开
连接主机(代理服务器)...
连接主机成功
Last login: Tue Mar 11 20:00:02 2025 from 36.231.147.45
Welcome to Alibaba Cloud Elastic Compute Service !
[root@iZbp11gpxfapiize7sb6ixZ ~]# pip3 install mysqlclient==2.1.0
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting mysqlclient==2.1.0
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/de/79/d02be3cb942afda6c99ca207858847572e38146eb73a7c4bfe3bdf154626/mysqlclient-2.1.0.tar.gz (87 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.6/87.6 kB 11.3 MB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
/bin/sh: mysql_config: 未找到命令
/bin/sh: mariadb_config: 未找到命令
/bin/sh: mysql_config: 未找到命令
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-6saietvb/mysqlclient_6bc2f891c73b4266865ef83dd098a596/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-install-6saietvb/mysqlclient_6bc2f891c73b4266865ef83dd098a596/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-6saietvb/mysqlclient_6bc2f891c73b4266865ef83dd098a596/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
mysql_config --version
mariadb_config --version
mysql_config --libs
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 删除原系统上的包
rpm -qa | grep mysql | xargs sudo rpm -e --nodeps
rpm -qa | grep mariadb | xargs sudo rpm -e --nodeps
1
2
2
# 安装依赖包
rpm -ivh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
yum install -y mysql-community-common-5.7.43-1.el7.x86_64 --nogpgcheck
yum install -y mysql-community-libs-5.7.43-1.el7.x86_64 --nogpgcheck
yum install -y mysql-community-libs-compat-5.7.43-1.el7.x86_64 --nogpgcheck
yum install -y mysql-community-devel-5.7.43-1.el7.x86_64 --nogpgcheck
1
2
3
4
5
2
3
4
5
# 安装mysqlclient
pip3 install mysqlclient
1
上次更新: 2025/03/11, 12:44:31