ImportError: cannot import name 'gettext_lazy' from partially initialized module 'django.utils.translation'

Hello Django developer,

How can I solve this error? I show Django documentation in a new version.(Translation | Django documentation | Django). I’ve read it , and I still can’t get it to work.

ImportError: cannot import name 'gettext_lazy' from partially initialized module 'django.utils.translation'

Any sort of help would be highly appreciated.

This partically initilized error might happen when you have file with the same name as the thing you are trying to import. Is that the case?

This is error shown:

 raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

I’ve already used virtualenv. How should I fix it, I’ve installed Django, all packages and dependencies.

Please post the complete traceback for the error you’re getting.

Traceback (most recent call last):
  File "C:\Users\' '\Desktop\spine\manage.py", line 11, in main
    from django.core.management import execute_from_command_line
  File "C:\Users\' '\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 16, in <module>
    from django.core.management.base import (
  File "C:\Users\' '\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 13, in <module>
    from django.core import checks
  File "C:\Users\' '\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\__init__.py", line 18, in <module>
    import django.core.checks.translation  # NOQA isort:skip
  File "C:\Users\' '\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\translation.py", line 2, in <module>
    from django.utils.translation import get_supported_language_variant
  File "C:\Users\'  '\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\translation\__init__.py", line 13, in <module>
    from django.utils.translation import gettext_lazy as _
ImportError: cannot import name 'gettext_lazy' from partially initialized module 'django.utils.translation' (most likely due to a circular import) (C:\Users\' '\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\translation\__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\'  '\Desktop\spine\manage.py", line 22, in <module>
    main()
  File "C:\Users\' '\Desktop\spine\manage.py", line 13, in main
    raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

Hi there,
I have the same issue ImportError: cannot import name ‘ugettext’ from ‘django.utils.translation’ (/usr/local/lib/python3.12/site-packages/django/utils/translation/init.py). Did you mean: ‘gettext’?
I am using Django==4.2. Thank you in advance for your help.

This is a different issue.

ugettext was deprecated in Django 3.0. See Django 3.0 release notes | Django documentation | Django

Hi @KenWhitesell, sorry for the late response if you’re working on Django 4.* then just use gettext_lazy instead of “ugettext”.