Python 3 ImportError: No module named 'ConfigParser'

前端 未结 18 2280
半阙折子戏
半阙折子戏 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:33

    I was having the same problem. Turns out, I needed to install python3 devel on my centos. First, you need to search for the package that is compatible with your system.

    yum search python3 | grep devel
    

    Then, install the package as:

    yum install -y python3-devel.x86_64
    

    Then, install mysqlclient from pip

    pip install mysqlclient
    
    0 讨论(0)
  • 2020-11-22 13:36

    Kindly to see what is /usr/bin/python pointing to

    if it is pointing to python3 or higher change to python2.7

    This should solve the issue.

    I was getting install error for all the python packages. Abe Karplus's solution & discussion gave me the hint as to what could be the problem. Then I recalled that I had manually changed the /usr/bin/python from python2.7 to /usr/bin/python3.5, which actually was causing the issue. Once I reverted the same. It got solved.

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

    MySQL-python is not supported on python3 instead of this you can use mysqlclient

    If you are on fedora/centos/Red Hat install following package

    1. yum install python3-devel
    2. pip install mysqlclient
    0 讨论(0)
  • 2020-11-22 13:39

    Compatibility of Python 2/3 for configparser can be solved simply by six library

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

    Try this solution which worked fine for me.

    Basically it's to reinstall/upgrade to latest version of mysql from brew, and then installing mysqlclient or MySQL-Python from global pip3 instead of virtualenv pip3.

    Then accessing the virtualenv and successfully install mysqlclient or MySQL-Python.

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

    I was getting the same error on Mac OS 10, Python 3.7.6 & Django 2.2.7. I want to use this opportunity to share what worked for me after trying out numerous solutions.

    Steps

    1. Installed Connector/Python 8.0.20 for Mac OS from link

    2. Copy current dependencies into requirements.txt file, deactivated the current virtual env, and deleted it using;

      create the file if not already created with; touch requirements.txt

      copy dependency to file; python -m pip3 freeze > requirements.txt

      deactivate and delete current virtual env; deactivate && rm -rf <virtual-env-name>

    3. Created another virtual env and activated it using; python -m venv <virtual-env-name> && source <virtual-env-name>/bin/activate

    4. Install previous dependencies using; python -m pip3 install -r requirements.txt

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