Django - RuntimeError: populate() isn't reentrant
Question: I'm trying to move my Django project to a production server(virtual machine
running ubuntu server 14.04 LTS X64) freshly installed.

All I did so far is installing the project requirements.txt (no apache server
installed nor mysql server)

When I try to run `manage.py runserver` I get this error:

    
    
    Traceback (most recent call last):
      File "manage.py", line 10, in <module>
        execute_from_command_line(sys.argv)
      File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
        utility.execute()
      File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 354, in execute
        django.setup()
      File "/usr/local/lib/python3.4/site-packages/django/__init__.py", line 21, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/usr/local/lib/python3.4/site-packages/django/apps/registry.py", line 78, in populate
        raise RuntimeError("populate() isn't reentrant")
    RuntimeError: populate() isn't reentrant
    

I have no idea how to trace the source of this issue, and if you need any
information let me know.

requirements.txt:

    
    
    amqp==1.4.9
    anyjson==0.3.3
    billiard==3.3.0.22
    celery==3.1.19
    dj-database-url==0.3.0
    dj-static==0.0.6
    Django==1.7.1
    django-appconf==0.6
    django-celery==3.1.17
    django-compressor==1.4
    django-discover-runner==1.0
    django-role-permissions==0.6.2
    djangorestframework==3.0.0
    drf-nested-routers==0.11.1
    gunicorn==19.1.1
    kombu==3.0.33
    mysql-connector-python==2.1.3
    pytz==2015.7
    six==1.8.0
    static3==0.5.1
    


Answer: After trying running `manage.py`alone, i got this error :

    
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 108, in load_backend
        return import_module('%s.base' % backend_name)
      File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
    ImportError: No module named 'mysql'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
        settings.INSTALLED_APPS
      File "/usr/local/lib/python3.4/site-packages/django/conf/__init__.py", line 46, in __getattr__
        self._setup(name)
      File "/usr/local/lib/python3.4/site-packages/django/conf/__init__.py", line 42, in _setup
        self._wrapped = Settings(settings_module)
      File "/usr/local/lib/python3.4/site-packages/django/conf/__init__.py", line 94, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 1129, in _exec
      File "<frozen importlib._bootstrap>", line 1471, in exec_module
      File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
      File "/home/soufiaane/django_projects/CapValue/CapValue/__init__.py", line 5, in <module>
        from .celery_settings import app as celery_app  # noqa
      File "/home/soufiaane/django_projects/CapValue/CapValue/celery_settings.py", line 9, in <module>
        django.setup()
      File "/usr/local/lib/python3.4/site-packages/django/__init__.py", line 21, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/usr/local/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
        app_config.import_models(all_models)
      File "/usr/local/lib/python3.4/site-packages/django/apps/config.py", line 202, in import_models
        self.models_module = import_module(models_module_name)
      File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "/usr/local/lib/python3.4/site-packages/django/contrib/auth/models.py", line 40, in <module>
        class Permission(models.Model):
      File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 124, in __new__
        new_class.add_to_class('_meta', Options(meta, **kwargs))
      File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 299, in add_to_class
        value.contribute_to_class(cls, name)
      File "/usr/local/lib/python3.4/site-packages/django/db/models/options.py", line 166, in contribute_to_class
        self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
      File "/usr/local/lib/python3.4/site-packages/django/db/__init__.py", line 40, in __getattr__
        return getattr(connections[DEFAULT_DB_ALIAS], item)
      File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 242, in __getitem__
        backend = load_backend(db['ENGINE'])
      File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 126, in load_backend
        raise ImproperlyConfigured(error_msg)
    django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.
    Try using 'django.db.backends.XXX', where XXX is one of:
        'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
    Error was: No module named 'mysql'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "manage.py", line 10, in <module>
        execute_from_command_line(sys.argv)
      File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
        utility.execute()
      File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 351, in execute
        settings.configure()
      File "/usr/local/lib/python3.4/site-packages/django/conf/__init__.py", line 56, in configure
        raise RuntimeError('Settings already configured.')
    RuntimeError: Settings already configured.
    

which clearly indicates that i have an issue regarding mysql database support!

after struggeling with the mysql-connector-python package i was using in my
devloppment version, i couldn't get it working on my linux server due to some
compatibility issues.

so i end up installing mysqlclient package insteed and it worked like a charm!

