Search code examples
pythondjangopippython-3.6django-cms

djangocms - cannot import name 'NamespaceAlreadyRegistered'


I have developed a simple project with DjangoCMS(3.7.2) and it works great in the local. I 'm gonna run it on a ubuntu server, which I have another Django project run on it with no issues. Both of my projects are built using python 3.6 & MySQL database. I took these steps to run my new project:

  1. Cloned the project from the server via git and updated the settings.py file
  2. Created an empty database on the server
  3. Installed a virtualenv on server by python3 -m venv venv
  4. Activated the venv and upgraded pip
  5. Installed requirements successfully using pip install -r requirements.txt
  6. Tried to Migrate by python3 manage.py migrate

But I got this error:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/var/www/pishbiny/myenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/var/www/pishbiny/myenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "/var/www/pishbiny/myenv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/var/www/pishbiny/myenv/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/var/www/pishbiny/myenv/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/www/pishbiny/myenv/lib/python3.6/site-packages/cms/models/__init__.py", line 3, in <module>
    from .pagemodel import *  # nopyflakes
  File "/var/www/pishbiny/myenv/lib/python3.6/site-packages/cms/models/pagemodel.py", line 31, in <module>
    from menus.menu_pool import menu_pool
  File "/var/www/pishbiny/myenv/lib/python3.6/site-packages/menus/menu_pool.py", line 18, in <module>
    from menus.exceptions import NamespaceAlreadyRegistered
ImportError: cannot import name 'NamespaceAlreadyRegistered'

  • Following dependencies are installed on the server:
asgiref                    3.2.7
chardet                    3.0.4
cms                        0.0.2
dj-database-url            0.5.0
Django                     3.0.5
django-classy-tags         1.0.0
django-cms                 3.7.2
django-filer               1.7.0
django-formtools           2.2
django-js-asset            1.2.2
django-mptt                0.11.0
django-polymorphic         2.1.2
django-sekizai             1.1.0
django-treebeard           4.3.1
djangocms-admin-style      1.5.0
djangocms-attributes-field 1.2.0
djangocms-bootstrap4       1.6.0
djangocms-file             2.4.0
djangocms-googlemap        1.4.0
djangocms-icon             1.5.0
djangocms-installer        1.2.3
djangocms-link             2.6.0
djangocms-picture          2.4.0
djangocms-snippet          2.3.0
djangocms-style            2.3.0
djangocms-text-ckeditor    3.9.0
djangocms-video            2.3.0
dsdev-utils                1.0.4
easy-thumbnails            2.7
html5lib                   1.0.1
Menus                      0.2.0
mysqlclient                1.4.6
Pillow                     7.1.2
pip                        20.1
pkg-resources              0.0.0
pytz                       2020.1
setuptools                 39.0.1
six                        1.14.0
sqlparse                   0.3.1
tzlocal                    2.0.0
Unidecode                  1.1.1
webencodings               0.5.1
wheel                      0.34.2

I removed the venv and reinstalled all the dependencies several times, but it didn't work. Let me know what is my mistake. Many thanks in advance for any help you could provide.


Solution

  • As Alasdair mentioned:

    I reinstalled the Django-CMS module by running python3 -m pip install "django-cms==3.7.2", and surprisingly it worked.