質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

解決済

3回答

11960閲覧

OSError: [WinError 123] ファイル名、ディレクトリ名、またはボリューム ラベルの構文が間違っています。: '<frozen importlib._bootstrap>'

ingramzero

総合スコア16

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2019/07/08 06:05

編集2019/07/08 06:48

前提・実現したいこと

参考にしたサイトのチュートリアル↓↓
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.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hayataka2049

2019/07/08 06:10

エラーの本体はModuleNotFoundError: No module named 'polls'の方なんですね。で、参考にしているチュートリアルのサイト、pythonとdjangoのバージョンを教えてください。あと、コードやエラーは<code>ボタンで挿入できるコードブロックの中に張り付けてください(そうしないとすごく読みづらいです)。
guest

回答3

0

自己解決

解決方法を探っていた所、mysiteの階層とpollsの階層が違っていたのでpollsが認識されませんでした。
なので階層を変えてrunserverコマンドを実行したところうまく動いてくれました。お騒がせしました。ありがとうございます。

投稿2019/07/08 15:01

ingramzero

総合スコア16

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

明確な間違い一箇所。

patch

1- path(' ', views.index, name='index'), 2+ path('', views.index, name='index'),

あとは、mysite/settings.pyを直すといけるという情報がちょくちょくネットに上がっているので、この辺も確認を(ModuleNotFoundError: No module named 'polls'で検索するといろいろ出てきますが、違うバージョンの情報のほうが多いので、使っているバージョンでどうなっているのかはわかりません)

投稿2019/07/08 06:54

hayataka2049

総合スコア30933

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ingramzero

2019/07/08 08:27

hayataka2049さん、何度もありがとうございます。 path('',views.index, name='index'),に直し、mysite/settings.pyを直したのですが上手くいきません。 引き続きエラーの原因を探っていきたいと思います。
guest

0

その出ているエラーメッセージのとおり、としか言いようがないですが、エラーが出ている箇所でのファイル指定がどうなってるのか見てみたらどうでしょう

#ソースが読める状態ではないのでどーにも

投稿2019/07/08 06:49

y_waiwai

総合スコア87774

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問