'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>'
Solution 1:[1]
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
Solution 2:[2]
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
Solution 3:[3]
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!
Solution 4:[4]
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)
Solution 5:[5]
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.
Solution 6:[6]
In my case, the issue resolved after
- python manage.py makemigrations
- python manage.py migrate
- python manage.py runserver
It worked fine after above.
Solution 7:[7]
The same problem happened to me. In my case, I wrote 'rest-framework' instead of 'rest_framework' in INSTALLED_APPS. Check that too.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David |
| Solution 2 | CodenificienT |
| Solution 3 | |
| Solution 4 | |
| Solution 5 | flyingduck92 |
| Solution 6 | Subhasish Paul |
| Solution 7 | user2809967 |
