python3导入错误:没有名为'configparser'的模块

li9yvcax  于 2021-06-20  发布在  Mysql
关注(0)|答案(18)|浏览(1066)

我正在努力 pip install 这个 MySQL-python 包裹,但我有一个 ImportError .

Jans-MacBook-Pro:~ jan$ /Library/Frameworks/Python.framework/Versions/3.3/bin/pip-3.3 install MySQL-python
Downloading/unpacking MySQL-python
  Running setup.py egg_info for package MySQL-python
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
        from setup_posix import get_config
      File "./setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>

    from setup_posix import get_config

  File "./setup_posix.py", line 2, in <module>

    from ConfigParser import SafeConfigParser

ImportError: No module named 'ConfigParser'

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python
Storing complete log in /Users/jan/.pip/pip.log
Jans-MacBook-Pro:~ jan$

有什么想法吗?

evrscar2

evrscar216#

python 2/3的兼容性 configparser 可以简单地通过 six 图书馆

from six.moves import configparser
pdkcd3nj

pdkcd3nj17#

你可以用 mysqlclient 包作为mysql-python的替代品。这是一把叉子 MySQL-python 添加了对python3的支持。
我很幸运

pip install mysqlclient

在我的python3.4virtualenv之后

sudo apt-get install python3-dev libmysqlclient-dev

这显然是针对ubuntu/debian的,但我只想分享我的成功:)

dfuffjeb

dfuffjeb18#

我也有同样的问题。结果,我需要在centos上安装python3-devel。首先,您需要搜索与您的系统兼容的包。

yum search python3 | grep devel

然后,将软件包安装为:

yum install -y python3-devel.x86_64

然后,从pip安装mysqlclient

pip install mysqlclient

相关问题