Home>

Referenced site tutorial ↓↓
https://docs.djangoproject.com/en/2.2/intro/tutorial01/

Version:
Python 3.7.3
Django 2.2.3

Executed with the integrated environment Pycharm command.

Error message
(django) C: \ Users \ ichik \ PycharmProjects \ djangotest>python mysite/manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ threading.py", line 917, in _bootstrap_inner
    self.run ()
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ threading.py", line 865, in run
    self._target (* self._args, ** self._kwargs)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 54, in wrapper
    fn (* args, ** kwargs)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ commands \ runserver.py", line 109, in inner_run
    autoreload.raise_last_exception ()
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 77, in raise_last_exception
    raise _exception [1]
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ __ init__.py", line 337, in execute
    autoreload.check_errors (django.setup) ()
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 54, in wrapper
    fn (* args, ** kwargs)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ __ init__.py", line 24, in setup
    apps.populate (settings.INSTALLED_APPS)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ apps \ registry.py", line 91, in populate
    app_config = AppConfig.create (entry)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ apps \ config.py", line 90, in create
    module = import_module (entry)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ importlib \ __ init__.py", line 127, in import_module
    return _bootstrap._gcd_import (name [level:],

 package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlockedModuleNotFoundError: No module named 'polls'
Traceback (most recent call last):
  File "mysite/manage.py", line 21, in<module>
    main ()
  File "mysite/manage.py", line 17, in main
    execute_from_command_line (sys.argv)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ __ init__.py", line 381, in execute_from_command_line
    utility.execute ()
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ __ init__.py", line 375, in execute
    self.fetch_command (subcommand) .run_from_argv (self.argv)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ base.py", line 323, in run_from_argv
    self.execute (* args, ** cmd_options)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ commands \ runserver.py", line 60, in execute
    super (). execute (* args, ** options)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ base.py", line 364, in execute
    output = self.handle (* args, ** options)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ commands \ runserver.py", line 95, in handle
    self.run (** options)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ core \ management \ commands \ runserver.py", line 102, in run
    autoreload.run_with_reloader (self.inner_run, ** options)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 587, in run_with_reloader
    start_django (reloader, main_func, * args, ** kwargs)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 572, in start_django
    reloader.run (django_main_thread)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 290, in run
    self.run_loop ()
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 296, in run_loop
    next (ticker)
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 336, in tick
    for filepath, mtime in self.snapshot_files ():
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 352, in snapshot_files
    for file in self.watched_files ():
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 251, in watched_files
    yield from iter_all_python_module_files ()
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 103, in iter_all_python_module_files
    return iter_modules_and_files (modules, frozenset (_error_files))
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ site-packages \ django \ utils \ autoreload.py", line 138, in iter_modules_and_files
    if not path.exists ():
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ pathlib.py", line 1339, in existsself.stat ()
  File "C: \ Users \ ichik \ Anaconda3 \ envs \ django \ lib \ pathlib.py", line 1161, in stat
    return self._accessor.stat (self)
OSError: [WinError 123] The file name, directory name, or volume label syntax is incorrect. : '<frozen importlib._bootstrap>'
Applicable source code mysite/urls.py
"" "mysite URL Configuration
The `urlpatterns` list routes URLs to views.For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import: from my_app import views
    2. Add a URL to urlpatterns: path ('', views.home, name = 'home')
Class-based views
    1. Add an import: from other_app.views import Home
    2. Add a URL to urlpatterns: path ('', Home.as_view (), name = 'home')
Including another URLconf
    1. Import the include () function: from django.urls import include, path
    2. Add a URL to urlpatterns: path ('blog /', include ('blog.urls'))
"" "
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
    path ('polls /', include ('polls.urls')),
    path ('admin /', admin.site.urls),
]
polls/urls.py
from django.urls import path
from .import views
urlpatterns = [
    path ('', views.index, name = 'index'),
]
polls/views.py
from django.shortcuts import render
from django.http import HttpResponse
def index (request):
    return HttpResponse ("Hello, world. You're at the polls index.")
# Create your views here.
  • Answer # 1

    I was looking for a solution, and myls hierarchy was different from polls hierarchy, so polls was not recognized.
    So when I changed the hierarchy and ran the runserver command, it worked fine. I apologize to you for a fuss over. Thank you very much.