前提・実現したいこと
参考にしたサイトのチュートリアル↓↓
https://docs.djangoproject.com/en/2.2/intro/tutorial01/
バージョン:
Python 3.7.3
Django 2.2.3
統合環境Pycharmのコマンドにて実行しました。
発生している問題・エラーメッセージ
python
1(django) C:\Users\ichik\PycharmProjects\djangotest>python mysite/manage.py runserver 2Watching for file changes with StatReloader 3Exception in thread django-main-thread: 4Traceback (most recent call last): 5 File "C:\Users\ichik\Anaconda3\envs\django\lib\threading.py", line 917, in _bootstrap_inner 6 self.run() 7 File "C:\Users\ichik\Anaconda3\envs\django\lib\threading.py", line 865, in run 8 self._target(*self._args, **self._kwargs) 9 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper 10 fn(*args, **kwargs) 11 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run 12 autoreload.raise_last_exception() 13 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception 14 raise _exception[1] 15 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\__init__.py", line 337, in execute 16 autoreload.check_errors(django.setup)() 17 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper 18 fn(*args, **kwargs) 19 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\__init__.py", line 24, in setup 20 apps.populate(settings.INSTALLED_APPS) 21 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\apps\registry.py", line 91, in populate 22 app_config = AppConfig.create(entry) 23 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\apps\config.py", line 90, in create 24 module = import_module(entry) 25 File "C:\Users\ichik\Anaconda3\envs\django\lib\importlib\__init__.py", line 127, in import_module 26 return _bootstrap._gcd_import(name[level:], package, level) 27 File "<frozen importlib._bootstrap>", line 1006, in _gcd_import 28 File "<frozen importlib._bootstrap>", line 983, in _find_and_load 29 File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked 30ModuleNotFoundError: No module named 'polls' 31 32Traceback (most recent call last): 33 File "mysite/manage.py", line 21, in <module> 34 main() 35 File "mysite/manage.py", line 17, in main 36 execute_from_command_line(sys.argv) 37 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line 38 utility.execute() 39 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\__init__.py", line 375, in execute 40 self.fetch_command(subcommand).run_from_argv(self.argv) 41 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv 42 self.execute(*args, **cmd_options) 43 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute 44 super().execute(*args, **options) 45 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\base.py", line 364, in execute 46 output = self.handle(*args, **options) 47 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle 48 self.run(**options) 49 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run 50 autoreload.run_with_reloader(self.inner_run, **options) 51 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 587, in run_with_reloader 52 start_django(reloader, main_func, *args, **kwargs) 53 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 572, in start_django 54 reloader.run(django_main_thread) 55 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 290, in run 56 self.run_loop() 57 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 296, in run_loop 58 next(ticker) 59 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 336, in tick 60 for filepath, mtime in self.snapshot_files(): 61 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 352, in snapshot_files 62 for file in self.watched_files(): 63 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 251, in watched_files 64 yield from iter_all_python_module_files() 65 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files 66 return iter_modules_and_files(modules, frozenset(_error_files)) 67 File "C:\Users\ichik\Anaconda3\envs\django\lib\site-packages\django\utils\autoreload.py", line 138, in iter_modules_and_files 68 if not path.exists(): 69 File "C:\Users\ichik\Anaconda3\envs\django\lib\pathlib.py", line 1339, in exists 70 self.stat() 71 File "C:\Users\ichik\Anaconda3\envs\django\lib\pathlib.py", line 1161, in stat 72 return self._accessor.stat(self) 73OSError: [WinError 123] ファイル名、ディレクトリ名、またはボリューム ラベルの構文が間違っています。: '<frozen importlib._bootstrap>' 74
該当のソースコード
mysite/urls.py
python
1"""mysite URL Configuration 2 3The `urlpatterns` list routes URLs to views. For more information please see: 4 https://docs.djangoproject.com/en/2.2/topics/http/urls/ 5Examples: 6Function views 7 1. Add an import: from my_app import views 8 2. Add a URL to urlpatterns: path('', views.home, name='home') 9Class-based views 10 1. Add an import: from other_app.views import Home 11 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12Including another URLconf 13 1. Import the include() function: from django.urls import include, path 14 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15""" 16from django.contrib import admin 17from django.urls import include, path 18 19urlpatterns = [ 20 path('polls/', include('polls.urls')), 21 path('admin/', admin.site.urls), 22] 23
polls/urls.py
python
1from django.urls import path 2 3from . import views 4 5urlpatterns = [ 6 path(' ', views.index, name='index'), 7]
polls/views.py
python
1from django.shortcuts import render 2from django.http import HttpResponse 3 4def index(request): 5 return HttpResponse("Hello, world. You're at the polls index.") 6 7# Create your views here.
エラーの本体はModuleNotFoundError: No module named 'polls'の方なんですね。で、参考にしているチュートリアルのサイト、pythonとdjangoのバージョンを教えてください。あと、コードやエラーは<code>ボタンで挿入できるコードブロックの中に張り付けてください(そうしないとすごく読みづらいです)。

回答3件
あなたの回答
tips
プレビュー