Django出现UnicodeDecodeError: 'utf-8' codec can't decode byte 0xda in position 134: invalid
生活随笔
收集整理的這篇文章主要介紹了
Django出现UnicodeDecodeError: 'utf-8' codec can't decode byte 0xda in position 134: invalid
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
完整報錯:
(python3.7) appleyuchi@ubuntu19:fenye$ python manage.py runserver 10071
Traceback (most recent call last):File "manage.py", line 15, in <module>execute_from_command_line(sys.argv)File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_lineutility.execute()File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 345, in executesettings.INSTALLED_APPSFile "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__self._setup(name)File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setupself._wrapped = Settings(settings_module)File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__mod = importlib.import_module(self.SETTINGS_MODULE)File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/importlib/__init__.py", line 127, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 1006, in _gcd_importFile "<frozen importlib._bootstrap>", line 983, in _find_and_loadFile "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "<frozen importlib._bootstrap>", line 1006, in _gcd_importFile "<frozen importlib._bootstrap>", line 983, in _find_and_loadFile "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 677, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 724, in exec_moduleFile "<frozen importlib._bootstrap_external>", line 857, in get_codeFile "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xda in position 134: invalid continuation byte
這里的原因是sed修改了*.pyc文件,所以Django會從*.pyc啟動.
但是因為編譯器只會提示.py文件的報錯,而不會提示*.pyc的報錯.
由此導致你會發現報錯位置在開源包的地方,而不是自己的工程文件所在處解決方案:
$ find . -name "*.pyc" | xargs rm -f
$ python manage.py runserver 10071
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, front, sessions.
Run 'python manage.py migrate' to apply them.February 06, 2020 - 11:55:13
Django version 3.0.2, using settings 'fenye.settings'
Starting development server at http://127.0.0.1:10071/
Quit the server with CONTROL-C.
OK,解決
總結
以上是生活随笔為你收集整理的Django出现UnicodeDecodeError: 'utf-8' codec can't decode byte 0xda in position 134: invalid的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: css3加载图片淡入效果
- 下一篇: html放缩都让内容处于正中间