问题
root@iZj6c0yks0kczty7tn77eaZ:~# pip3 install mysqlclient
Collecting mysqlclient
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/73/79/67ddf24ac31b05d741f0ac87fa612c7a11bab1b39b8270ed7344d149f8af/mysqlclient-1.4.2.tar.gz (85kB)
100% |████████████████████████████████| 92kB 52.1MB/s
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-1kuojk5w/mysqlclient/setup.py", line 16, in
metadata, options = get_config()
File "/tmp/pip-build-1kuojk5w/mysqlclient/setup_posix.py", line 51, in get_config
libs = mysql_config("libs")
File "/tmp/pip-build-1kuojk5w/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1kuojk5w/mysqlclient/
解决办法
先安装 libmysqlclient-dev
root@iZj6c0yks0kczty7tn77eaZ:~# apt install libmysqlclient-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libopts25 sntp
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libmysqlclient20 zlib1g-dev
The following NEW packages will be installed:
libmysqlclient-dev zlib1g-dev
The following packages will be upgraded:
libmysqlclient20
1 upgraded, 2 newly installed, 0 to remove and 94 not upgraded.
Need to get 2,157 kB of archives.
After this operation, 7,451 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 libmysqlclient20 amd64 5.7.25-0ubuntu0.18.04.2 [818 kB]
Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu bionic/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-0ubuntu2 [176 kB]
Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 libmysqlclient-dev amd64 5.7.25-0ubuntu0.18.04.2 [1,164 kB]
Fetched 2,157 kB in 0s (17.7 MB/s)
(Reading database ... 111396 files and directories currently installed.)
Preparing to unpack .../libmysqlclient20_5.7.25-0ubuntu0.18.04.2_amd64.deb ...
Unpacking libmysqlclient20:amd64 (5.7.25-0ubuntu0.18.04.2) over (5.7.24-0ubuntu0.18.04.1) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../zlib1g-dev_1%3a1.2.11.dfsg-0ubuntu2_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.11.dfsg-0ubuntu2) ...
Selecting previously unselected package libmysqlclient-dev.
Preparing to unpack .../libmysqlclient-dev_5.7.25-0ubuntu0.18.04.2_amd64.deb ...
Unpacking libmysqlclient-dev (5.7.25-0ubuntu0.18.04.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libmysqlclient20:amd64 (5.7.25-0ubuntu0.18.04.2) ...
Setting up zlib1g-dev:amd64 (1:1.2.11.dfsg-0ubuntu2) ...
Setting up libmysqlclient-dev (5.7.25-0ubuntu0.18.04.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
root@iZj6c0yks0kczty7tn77eaZ:~# pip3 install mysqlclient
Collecting mysqlclient
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/73/79/67ddf24ac31b05d741f0ac87fa612c7a11bab1b39b8270ed7344d149f8af/mysqlclient-1.4.2.tar.gz (85kB)
100% |████████████████████████████████| 92kB 39.5MB/s
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... done
Stored in directory: /root/.cache/pip/wheels/14/ee/fb/a87e678e5e1737f95e6b268460a830ef87b921e1d83a60fa08
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.2
root@iZj6c0yks0kczty7tn77eaZ:~#