简体   繁体   中英

django-cms makemigrations error: No module named 'packaging'

I am starting out in django-cms and I am trying to install cms from the official cms documentation. I created my virtual environment and installed Django and django-cms.

The next steps are to create a project with django-admin, and adding the django-cms in the installed apps. The project is going great till now. But, when I try to migrate my installed apps in the database I get the error "No module named 'packaging'". I don't understand what I am doing wrong. Another tutorial tells me to startproject using

djangocms myproject

but it doesn't work (it's probably outdated as I couldn't find any variations anywhere else)

My settings.py:

INSTALLED_APPS = [
    'djangocms_admin_style',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'cms',
    'menus',
    'treebeard',
]

SITE_ID = 1

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

LANGUAGE_CODE = 'en'
LANGUAGES = [
    ('en', 'English'),
]

After this, I run the py manage.py makemigrations But I get the error

Traceback (most recent call last):
  File "E:\art\Graphic Design\Coding\law-&-stuff\myproject\manage.py", line 22, in <module>
    main()
  File "E:\art\Graphic Design\Coding\law-&-stuff\myproject\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\django\core\management\__init__.py", line 420, in execute
    django.setup()
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\django\apps\registry.py", line 116, in populate
    app_config.import_models()
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\django\apps\config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\cms\models\__init__.py", line 4, in <module>
    from .placeholdermodel import *  # nopyflakes
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\cms\models\placeholdermodel.py", line 14, in <module>
    from cms.utils import get_language_from_request, get_site_id, permissions
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\cms\utils\permissions.py", line 13, in <module>
    from cms.utils.compat.dj import available_attrs
  File "E:\art\Graphic Design\Coding\law-&-stuff\venv\Lib\site-packages\cms\utils\compat\__init__.py", line 4, in <module>
    from packaging.version import Version
ModuleNotFoundError: No module named 'packaging'

I am following the documentation from https://docs.django-cms.org/en/latest/how_to/install.html . I think it might have something to do with how the packages have been installed? But, I don't understand how to fix it.

Found the solution!
The packaging module was not installed by default, I upgraded my pip with py -m pip install --upgrade pip and installed the module with py -m pip install packaging and it works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM