【问题标题】:pip3 install mysql-python failed with error code 1 in /tmp/pip-install-4nev4id4/mysql-python/pip3 install mysql-python 失败,错误代码 1 在 /tmp/pip-install-4nev4id4/mysql-python/
【发布时间】:2019-05-13 14:10:45
【问题描述】:

我是烧瓶上的 python 新手,当我尝试通过输入
安装 mysql-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 上检查过的许多人都建议这样做。

然后我重试安装mysql-python,但也出现同样的错误,谁能帮帮我。

【问题讨论】:

    标签: python mysql python-3.x pip mysql-python


    【解决方案1】:

    mysql-python 仅支持 Python 2.x,而您似乎使用的是 Python 3。来自链接的 PyPI 页面:

    目前 MySQL-3.23 到 5.5 和 Python-2.4 到 2.7 支持的。未来版本将支持 Python-3.0。

    要从 Python 3 连接到 MySQL,您可以使用其他替代方法:

    【讨论】:

      【解决方案2】:

      MySQL-python 不支持 python3。这就是为什么您会收到此特定错误

      ModuleNotFoundError: 没有名为“ConfigParser”的模块

      在python3中ConfigParser被重命名为configparser

      连接到 MySQL 数据库的一个选项是official python connector

      另一个选项是pyodbc

      其他答案中提供了其他选项

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-11-04
        • 2017-12-06
        • 1970-01-01
        • 2019-08-10
        • 2020-03-26
        • 2014-02-23
        • 1970-01-01
        • 2015-03-24
        相关资源
        最近更新 更多