当我尝试通过 在终端中输入以下命令来安装mysql-python时,我是Flask上的python新手
pip3 install mysql-python
它显示以下错误:
Collecting mysql-python Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-4nev4id4/mysql-python/setup.py", line 13, in <module> from setup_posix import get_config File "/tmp/pip-install-4nev4id4/mysql-python/setup_posix.py", line 2, in <module> from ConfigParser import SafeConfigParser ModuleNotFoundError: No module named 'ConfigParser' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-4nev4id4/mysql-python/
然后我sudo apt install default-libmysqlclient-dev在终端上使用了这个命令 ,这是很多我在stackoverflow上检查过的建议。
sudo apt install default-libmysqlclient-dev
然后我重试安装mysql-python,但它也显示相同的错误,有人可以帮助我。
mysql-python仅支持Python 2.x,而您似乎正在使用Python3。在链接的PyPI页面中:
当前支持MySQL-3.23至5.5和Python-2.4至2.7。将来的版本将支持Python-3.0。
要从Python 3连接到MySQL,您可以使用其他替代方法: