问题描述
我尝试了“ apt-get install python-MysqLdb”,结果是:
root@ps1svr:~# apt-get install python-MysqLdb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-MysqLdb 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 'python-MysqLdb' has no installation candidate
注意:“ apt-get install python3-MysqLdb”有效,但是我为Python 2.x编写了很多不再运行的代码,这引起了很多问题,我可能必须重新安装Ubuntu 18.04
解决方法
您也可以添加 Ubuntu 18.04 存储库来安装 python-mysqldb 包:
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu bionic main'
sudo apt update
sudo apt install -y python-mysqldb
,
这将使用 pip 为所有用户下载、构建和安装它
sudo apt install libmysqlclient-dev python2.7-dev
wget https://bootstrap.pypa.io/get-pip.py
sudo python2.7 get-pip.py
sudo wget https://raw.githubusercontent.com/paulfitz/mysql-connector-c/master/include/my_config.h -O /usr/include/mysql/my_config.h
sudo pip2 install MySQL-python
从MySQLdb install error - _mysql.c:44:23: error: my_config.h: No such file or directory找到的答案