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

Question:

I am using the DJango framework. I created a project in school using Pycharm and I wanted to create another project. However, when trying to run my server, all of the sudden I start to get the following error in my command prompt:

Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libthreading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libthreading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementcommandsrunserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementbase.py", line 392, in check
    all_issues = checks.run_checks(
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocorechecksregistry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocorechecksurls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocorechecksurls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsfunctional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangourlsresolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsfunctional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangourlsresolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libimportlib__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 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:UsersJohnnyPycharmProjectsDJango Tutorial V2mysitemysiteurls.py", line 20, in <module>
    path('polls/', include('polls.url')),
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangourlsconf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libimportlib__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 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'polls.url'
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagement__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagement__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementbase.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementcommandsrunserver.py", line 61, in execute
    super().execute(*args, **options)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementbase.py", line 371, in execute
    output = self.handle(*args, **options)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementcommandsrunserver.py", line 96, in handle
    self.run(**options)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementcommandsrunserver.py", line 103, in run
    autoreload.run_with_reloader(self.inner_run, **options)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 613, in run_with_reloader
    start_django(reloader, main_func, *args, **kwargs)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 598, in start_django
    reloader.run(django_main_thread)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 313, in run
    self.run_loop()
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 319, in run_loop
    next(ticker)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 359, in tick
    for filepath, mtime in self.snapshot_files():
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 375, in snapshot_files
    for file in self.watched_files():
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 274, in watched_files
    yield from iter_all_python_module_files()
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 105, in iter_all_python_module_files
    return iter_modules_and_files(modules, frozenset(_error_files))
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsautoreload.py", line 141, in iter_modules_and_files
    resolved_path = path.resolve(strict=True).absolute()
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libpathlib.py", line 1177, in resolve
    s = self._flavour.resolve(self, strict=strict)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libpathlib.py", line 200, in resolve
    return self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'

In my past project, I did have bootstrap installed but now I am not using it. I am also using a different python project interpreter. Why is it not working?

EDIT: Here is the error printed out:

C:UsersJohnnyPycharmProjectsDJango Tutorial V2mysite>python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagement__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagement__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementbase.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementbase.py", line 368, in execute
    self.check()
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocoremanagementbase.py", line 392, in check
    all_issues = checks.run_checks(
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocorechecksregistry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocorechecksurls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangocorechecksurls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsfunctional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangourlsresolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangoutilsfunctional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangourlsresolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libimportlib__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 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:UsersJohnnyPycharmProjectsDJango Tutorial V2mysitemysiteurls.py", line 20, in <module>
    path('polls/', include('polls.url')),
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libsite-packagesdjangourlsconf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "C:UsersJohnnyAppDataLocalProgramsPythonPython38libimportlib__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 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'polls.url'
Asked By: questions

||

Answers:

First of all check if you have incorrect file names for apps in INSTALLED APPS in settings.py. Your app should be sthg like:

INSTALLED_APPS = [
    'home.apps.HomeConfig' # or simply 'home' assuming all your app name,
    ......

]

Then, restart the server, if everything is good and still does not work.

In some cases the error is also shown because of migration. Try making migrations. Like:

python manage.py makemigrations
python manage.py migrate

You should be good to go by now.

Answered By: Biplove Lamichhane

Found it. Instead of polls.url, I wrote poll.url inside the url.py for the mysite package. Watch your spelling!

Answered By: questions

My folder in App was url.py

and in project setting i was writing path(”, include(‘loginaccounts.urls’)).

In path when I changed to url from urls it worked as it was not able to map the path.

Answered By: Kirti K

In my case, it was some corrupted migrations file. I deleted it and ran migrations afresh.

Answered By: kenosq
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.