Omboho
Omboho

Reputation: 31

Django runserver error- frozen importlib._bootstrap

I have been working on a project, and whenever I try the code:py manage.py runserver I get the error bellow. Kindly help to go about the error.

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

Upvotes: 3

Views: 24689

Answers (7)

Guzman Ojero
Guzman Ojero

Reputation: 3457

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?

No!

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.

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)

Upvotes: 1

LulzSec
LulzSec

Reputation: 39

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

Upvotes: 0

Subhasish Paul
Subhasish Paul

Reputation: 231

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.

Upvotes: 0

flyingduck92
flyingduck92

Reputation: 1644

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.

Upvotes: 0

Chris
Chris

Reputation: 41

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!

Upvotes: 0

CodenificienT
CodenificienT

Reputation: 21

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

Upvotes: 1

David
David

Reputation: 51

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

Upvotes: 2

Related Questions