1

The environment: visualvenv python3.6

Start the Django in venv, mysqlRemind no link

Start the Django in venv, mysqlRemind no link Start the Django in venv, mysqlRemind no linkStart the Django in venv, mysqlRemind no linkStart the Django in venv, mysqlRemind no linkStart the Django in venv, mysqlRemind no linkStart the Django in venv, mysqlRemind no link

python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x103a88048>
Traceback (most recent call last):
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 24, in <module>
    import MySQLdb as Database
ImportError: No module named 'MySQLdb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
    autoreload.raise_last_exception()
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
    six.reraise(*_exception)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/utils/six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/contrib/auth/models.py", line 41, in <module>
    class Permission(models.Model):
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/models/base.py", line 139, in __new__
    new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/models/base.py", line 324, in add_to_class
    value.contribute_to_class(cls, name)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/models/options.py", line 250, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/__init__.py", line 36, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/utils.py", line 241, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/utils.py", line 112, in load_backend
    return import_module('%s.base' % backend_name)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 27, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

 pip install MySQL-python
    Collecting MySQL-python
      Using cached MySQL-python-1.2.5.zip
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/private/var/folders/b2/3clz71qj661cjh_b3wg2jqcm0000gn/T/pip-build-zqh44_1k/MySQL-python/setup.py", line 13, in <module>
            from setup_posix import get_config
          File "/private/var/folders/b2/3clz71qj661cjh_b3wg2jqcm0000gn/T/pip-build-zqh44_1k/MySQL-python/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 /private/var/folders/b2/3clz71qj661cjh_b3wg2jqcm0000gn/T/pip-build-zqh44_1k/MySQL-python/
VanXv
  • 13
  • 1
  • 1
  • 5
  • Possible duplicate of [Python 3 ImportError: No module named 'ConfigParser'](http://stackoverflow.com/questions/14087598/python-3-importerror-no-module-named-configparser) – Bugs Mar 07 '17 at 10:11

1 Answers1

4

This issue is listed on github official repo here:

This change should do it. There were some minor incompatibilities with python 3 within django-mysqlndb-backend itself, but also the MySQL-python dependency is not python 3 compatible (which is where your ConfigParser error was coming from), whereas mysqlclient is. You may need to uninstall MySQL-python before reinstalling django-mysqlndb-backend in order for it to pull in the correct package.

Unfortunately someone created a PyPI package for this library on our behalf (it appears that it might be @enriqueaf ?) So unless they give the PyPi user "theatlantic" write access to that package you will just have to pip install from source. I recommend pinning it to a tag, e.g.:

pip install -e git+git://github.com/theatlantic/django-mysqlndb-backend.git@v1.1.0#egg=django-mysqlndb-backend

The question has also been asked on SO.

Community
  • 1
  • 1
Geoffroy
  • 86
  • 7
  • Edit. Thank you @Bugs – Geoffroy Mar 07 '17 at 09:54
  • 2
    Sorry to be a ball buster. I know you're new so don't think I'm having a go. Just trying to help. With links, you should provide context from you links in your answer just in case the link dies. Have a look at [How to write a great answer](http://stackoverflow.com/help/how-to-answer). Specifically _Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline._ – Bugs Mar 07 '17 at 09:57