[Django]-Django runserver error- frozen importlib._bootstrap

2👍

I had the same problem. I wasn’t in the virtual environment where I installed django crispy forms and then this error occured.

Maybe this can help

👤David

1👍

OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'

I kept getting this same error message after returning to my Django project a few weeks later. I could not trace the exact issues, but I was missing a few packages, namely, crispy_forms and Pillow.

I launched the virtual server using quotes "(path_to_django_project)\Script\activate.bat" then Enter. Install the missing packages

pip install Pillow then
pip install crispy-forms-gds

After PIP installing, I run some migrations

python manage.py makemigrations
python manage.py migrate

I started my local server, python manage.py runserver and view the project in the browser

0👍

If You look back in the Terminal, you could find the problem. I had a missing module, called django-filters.

ModuleNotFoundError: No module named 'django_filters'

After I installed it, I got another missing module, and so on. Sometimes, You should restart PyCharm to make it realise the new installations!
Finally, did a

python manage.py makemigrations

then

python manage.py migrate

then

python manage.py runserver

and everything works fine now!

👤Chris

0👍

This is similar to something that happened to me.

After checking the traceback message I’ve noticed the following:

File...       
ModuleNotFoundError: No module named '<app_name>'


File...
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'

In my specific case I have misspelled the name of the app in settings.py/INSTALLED_APPS, that’s why the ModuleNotFoundError.

Django was looking for <app_name>.apps.<app_name>Config(for instance: blog.apps.BlogConfig), but I had a typo (like this one: blogg.apps.BlogConfig) and Django raised an error.


Is Django or Python using the Bootstrap framework?

I’ve seen many answers claim that this error was because you didn’t have the Bootstrap framework installed and that’s wrong.

Let’s see the error again, but in more detail.

File "<...path_to_python...>\lib\importlib\__init__.py", line 127,
   in import_module return bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked

ModuleNotFoundError: No module named '<app_name>'


File...
OSError: [WinError 123] The filename, directory name, or volume label syntax
is incorrect: '<frozen importlib._bootstrap>'

Is this '<frozen importlib._bootstrap>' Bootstrap ? Nope.

Let’s see what’s happening in the Python source code.

Apparently the bootstrap reference is not about the CSS framework, but about the import internals in Python. Like the source code says:

#Lib/importlib/_bootstrap.py

Core implementation of import.

It all starts here, line 127.

 return _bootstrap._gcd_import(name[level:], package, level)

0👍

I have the same issue, when I run the project on git-bash terminal.
But when you run it on command prompt the project actually could run.

0👍

In my case, the issue resolved after

  1. python manage.py makemigrations
  2. python manage.py migrate
  3. python manage.py runserver

It worked fine after above.

0👍

The same problem happened to me. In my case, I wrote ‘rest-framework’ instead of ‘rest_framework’ in INSTALLED_APPS. Check that too.

Leave a comment