安装mysqlclient报错:OSError: mysql_config not found

mysqlclient 是一个 Python 程序包,它提供了一个 Python 的 MySQL 客户端库,用于连接和操作 MySQL 数据库。在安装 mysqlclient 之前,需要确保系统已经安装了 MySQL 的 C 客户端库,否则安装过程会失败。

环境安装:

如果使用传统的
apt-get install mysql-server
会报错:

# apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package mysql-client is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package mysql-server is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'mysql-server' has no installation candidate
E: Package 'mysql-client' has no installation candidate

换成一下命令即可:

apt-get install default-mysql-server
apt-get install default-mysql-client

安装好mysql环境后还需安装libmysqlclient-dev和python3-dev
同样命令还是需要修改:

root@e262e2b27b67:/home/together_album# apt-get install libmysqlclient-dev python3-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libmysqlclient-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libmariadb-dev-compat libmariadb-dev

E: Package 'libmysqlclient-dev' has no installation candidate

换成一下命令,即可

apt-get install default-libmysqlclient-dev python3-dev

安装好环境后就可以下载mysqlclient了
如下:

root@e262e2b27b67:/home/together_album# pip install mysqlclient
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting mysqlclient
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/50/5f/eac919b88b9df39bbe4a855f136d58f80d191cfea34a3dcf96bf5d8ace0a/mysqlclient-2.1.1.tar.gz (88 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... done
  Created wheel for mysqlclient: filename=mysqlclient-2.1.1-cp37-cp37m-linux_x86_64.whl size=114715 sha256=77f8bf6d5e3e8c4311b0132d1b9e3e93c8b468990804aeb09b3568b92688a5c6
  Stored in directory: /root/.cache/pip/wheels/3c/5c/f8/669aadcd2c552c9baaf835b360d375adc2cd97b99c5b3de312
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.1.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.0.1 -> 23.2
[notice] To update, run: pip install --upgrade pip

你可能感兴趣的:(mysql,adb,数据库)