Python 3 ImportError: No module named 'ConfigParser'

前端 未结 18 2298
半阙折子戏
半阙折子戏 2020-11-22 12:52

I am trying to pip install the MySQL-python package, but I get an ImportError.

Jans-MacBook-Pro:~ jan$ /Library/Framew         


        
相关标签:
18条回答
  • 2020-11-22 13:14

    You can instead use the mysqlclient package as a drop-in replacement for MySQL-python. It is a fork of MySQL-python with added support for Python 3.

    I had luck with simply

    pip install mysqlclient
    

    in my python3.4 virtualenv after

    sudo apt-get install python3-dev libmysqlclient-dev
    

    which is obviously specific to ubuntu/debian, but I just wanted to share my success :)

    0 讨论(0)
  • 2020-11-22 13:14

    For me the following command worked:

    sudo python3 -m pip install mysql-connector
    
    0 讨论(0)
  • 2020-11-22 13:15

    If you are using CentOS, then you need to use

    1. yum install python34-devel.x86_64
    2. yum groupinstall -y 'development tools'
    3. pip3 install mysql-connector
    4. pip install mysqlclient
    0 讨论(0)
  • 2020-11-22 13:16

    In Python 3, ConfigParser has been renamed to configparser for PEP 8 compliance. It looks like the package you are installing does not support Python 3.

    0 讨论(0)
  • 2020-11-22 13:19

    Here is a code that should work in both Python 2.x and 3.x

    Obviously you will need the six module, but it's almost impossible to write modules that work in both versions without six.

    try:
        import configparser
    except:
        from six.moves import configparser
    
    0 讨论(0)
  • 2020-11-22 13:20

    I run kali linux- Rolling and I came across this problem ,when I tried running cupp.py in the terminal, after updating to python 3.6.0. After some research and trial I found that changing ConfigParser to configparser worked for me but then I came across another issue.

    config = configparser.configparser() AttributeError: module 'configparser' has no attribute 'configparser'

    After a bit more research I realised that for python 3 ConfigParser is changed to configparser but note that it has an attribute ConfigParser().

    0 讨论(0)
提交回复
热议问题