ValueError: 源代码字符串不能包含空字节 -django

时间:2021-02-10 06:27:11

标签: python-3.x django traceback

这是我每次尝试运行服务器时得到的回溯。

C:\Users\sarathmahe024\Downloads\website (1)\website\website>python manage.py runserver
 

Traceback (most recent call last):
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\__init__.py", line 16, in setup
from django.urls import set_script_prefix
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\__init__.py", line 1, in <module>
from .base import (
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\base.py", line 9, in <module>
from .exceptions import NoReverseMatch, Resolver404
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
from django.http import Http404
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\http\__init__.py", line 5, in <module>
from django.http.response import (
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\http\response.py", line 15, in <module>
from django.core.serializers.json import DjangoJSONEncoder
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
from django.core.serializers.base import SerializerDoesNotExist
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\serializers\base.py", line 7, in <module>
from django.db import models
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
from django.db.models.aggregates import *  # NOQA
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
from django.db.models.expressions import Case, Func, Star, When
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\expressions.py", line 8, in <module>
from django.db.models import fields
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\fields\__init__.py", line 11, in <module>
from django import forms
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\forms\__init__.py", line 6, in <module>
from django.forms.boundfield import *  # NOQA
ValueError: source code string cannot contain null bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\sarathmahe024\Downloads\website (1)\website\website\manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line

utility.execute()
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 370, in execute
_parser = self.fetch_command('runserver').create_parser('django', 'runserver')
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 244, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 37, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
 File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\runserver.py", line 10, in <module>
from django.core.servers.basehttp import (
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\servers\basehttp.py", line 17, in <module>
from django.core.handlers.wsgi import LimitedStream
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\wsgi.py", line 5, in <module>
from django.core.handlers import base
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\base.py", line 11, in <module>
from django.urls import get_resolver, set_urlconf
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\__init__.py", line 1, in <module>
from .base import (
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\base.py", line 9, in <module>
from .exceptions import NoReverseMatch, Resolver404
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
from django.http import Http404
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\http\__init__.py", line 5, in <module>
from django.http.response import (
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\http\response.py", line 15, in <module>
from django.core.serializers.json import DjangoJSONEncoder
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
from django.core.serializers.base import SerializerDoesNotExist
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\serializers\base.py", line 7, in <module>
from django.db import models
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
from django.db.models.aggregates import *  # NOQA
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
from django.db.models.expressions import Case, Func, Star, When
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\expressions.py", line 8, in <module>
from django.db.models import fields
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\fields\__init__.py", line 11, in <module>
from django import forms
  File "C:\Users\sarathmahe024\AppData\Local\Programs\Python\Python39\lib\site-packages\django\forms\__init__.py", line 6, in <module>
from django.forms.boundfield import *  # NOQA
ValueError: source code string cannot contain null bytes

几个月前我遇到了同样的错误。然后我尝试重新安装对我有用的 pycharm。 我只是在这里尝试了相同的方法,但没有解决。真的很困惑什么可能是错误。 任何人都可以提出一种摆脱此错误的方法。 提前致谢。

0 个答案:

没有答案