Python Django runserver によるローカルサーバーの立ち上げエラー
Q&A
Closed
解決したいこと
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 0: invalid start byte
PythonのDjangoを初めて触りました。YouTubeやDocを見ながら進めていましたが「python manage.py runserver」を実行すると下記のようなエラーが出てしまいます。
発生している問題・エラー
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 0: invalid start byte
該当するソースコード
PS C:\Users\thisi\Programing\python-test\testPj> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
September 16, 2022 - 13:32:46
Django version 4.1, using settings 'testPj.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\pg\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\pg\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\pg\Python38\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\pg\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 158, in inner_run
run(
File "C:\pg\Python38\lib\site-packages\django\core\servers\basehttp.py", line 236, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File "C:\pg\Python38\lib\site-packages\django\core\servers\basehttp.py", line 76, in __init__
super().__init__(*args, **kwargs)
File "C:\pg\Python38\lib\socketserver.py", line 452, in __init__
self.server_bind()
File "C:\pg\Python38\lib\wsgiref\simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "C:\pg\Python38\lib\http\server.py", line 140, in server_bind
self.server_name = socket.getfqdn(host)
File "C:\pg\Python38\lib\socket.py", line 756, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 0: invalid start byte
自分で試したこと
Deeplで翻訳すると「utf-8' コーデックはポジション 0 のバイト 0x82 をデコードできません: 不正なスタートバイトです。」と書いてあり、manage.pyや同一フォルダのファイルはすべてUTF-8でした。またUTF-8にエンコードして保存をしてみましたがダメでした。
初歩的なミスですが改善点がわかる方は御享受願います。
またQiitaに初めて投稿するためご容赦ください。
0 likes