ImportError: No module named 'MySQLdb'

  1. 在python3.4 django 1.8环境中创建了一个project,在运行python manage.py runserver出现了如下问题:               ImportError: No module named 'MySQLdb'

[root@localhostmysite]# python manage.py runserver

Unhandledexception in thread started by .wrapperat 0x7f9487d3ef28>

Traceback(most recent call last):

  File"/usr/local/lib/python3.4/site-packages/django/db/backends/mysql/base.py",line 24, in

    import MySQLdb as Database

ImportError:No module named 'MySQLdb'

 

Duringhandling of the above exception, another exception occurred:

 

Traceback(most recent call last):

 

问题解决:需要安装pip install MySQL-python

 

来自 <https://segmentfault.com/q/1010000002539165>

 

但新的问题出现: ImportError: No module named 'ConfigParser'


[root@localhostmysite]# pip install MySQL-python

CollectingMySQL-python

  Using cached MySQL-python-1.2.5.zip

    Complete output from command pythonsetup.py egg_info:

    Traceback (most recent call last):

      File "", line 1,in

      File"/tmp/pip-build-xlcgim8c/MySQL-python/setup.py", line 13, in

        from setup_posix import get_config

      File"/tmp/pip-build-xlcgim8c/MySQL-python/setup_posix.py", line 2, in

        from ConfigParser importSafeConfigParser

    ImportError: No module named 'ConfigParser'

   

    ----------------------------------------

Command"python setup.py egg_info" failed with error code 1 in/tmp/pip-build-xlcgim8c/MySQL-python/

 

解决: 原来MySQL-python不支持python3,所以在python3环境下安装mysqlclient,问题最终解决

https://stackoverflow.com/questions/14087598/python-3-importerror-no-module-named-configparser

[root@localhostmysite]# pip install mysqlclient

你可能感兴趣的:(My,notes)