【无标题】pip install mysqlclient安装失败linux

pip install mysqlclient 报错:

Collecting mysqlclient
Using cached 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) … error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [42 lines of output]
mysql_config --version

原因可能是安装mysql数据库的源文件缺失,尝试了网上很多种方式,用以下代码解决了我的问题。

解决方案:

sudo apt-get update

sudo apt-get install libmysqlclient-dev

pip install mysqlclient

安装成功:

Collecting mysqlclient
Using cached 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-cp310-cp310-linux_x86_64.whl size=104288 sha256=cc599d162ea5df438c48ece51704d65ef89080fb55804d7de8ab70ae539fdf1f
Stored in directory: /home/changmin/.cache/pip/wheels/7d/34/ba/a769c165b01646816afdf9bf792e847ef149693fee432b6b65
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.1.1

你可能感兴趣的:(个人笔记,pip,linux,mysql,pycharm,python)