【问题标题】:Unable to install mysql-python library in Ubuntu 20.04 [duplicate]无法在 Ubuntu 20.04 中安装 mysql-python 库 [重复]
【发布时间】:2020-11-01 18:30:31
【问题描述】:

我尝试在ubuntu中安装mysql-python,但还是不成功,我之前用的是win10,从来没有遇到过这个问题。

我用pip3 install MySql-python

我遇到了以下错误:

Using cached MySQL-python-1.2.5.zip (108 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-j3febudn/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-j3febudn/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-j3febudn/mysql-python/pip-egg-info
         cwd: /tmp/pip-install-j3febudn/mysql-python/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-j3febudn/mysql-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/tmp/pip-install-j3febudn/mysql-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

【问题讨论】:

  • MySQL 在其页面上有专门的 Python 模块。也许用它来代替MySql-python - 请参阅connector/python - 甚至还有专门针对 Ubuntu 20.04 的版本。我将它与基于 Ubuntu 18.04 的 Linux Mint 19.3 一起使用
  • 顺便说一句:connector/python 的文档 - 您可以直接使用它,也可以在 SQLAlchemy 中使用它。
  • @furas THankyou,这实际上对我有用。

标签: python linux ubuntu mysql-python


【解决方案1】:

这似乎与:Python 3 ImportError: No module named 'ConfigParser'

简而言之,您的模块与 python3 不兼容,请使用其他模块或使用 python2,但不建议这样做,因为不推荐使用 python2。

【讨论】:

  • 我尝试了您在上述评论中提供的解决方案。但没有任何工作。我在使用 MySql-python、mysqlpython 时遇到同样的错误。
  • 你的错误信息是否像以前一样包含ModuleNotFoundError: No module named 'ConfigParser'
  • 是的,是一样的。也许我将不得不使用其他一些库,但我已经习惯了这个库。
猜你喜欢
  • 1970-01-01
  • 2021-05-21
  • 2021-01-28
  • 1970-01-01
  • 2021-08-10
  • 2021-05-02
  • 2020-10-03
  • 2021-05-24
  • 2021-11-28
相关资源
最近更新 更多