python报这个错误如何解决

python3 manage.py runserver
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 16, in setup
from django.urls import set_script_prefix
File "/usr/local/lib/python3.5/dist-packages/django/urls/__init__.py", line 1, in
from .base import (
File "/usr/local/lib/python3.5/dist-packages/django/urls/base.py", line 9, in
from .exceptions import NoReverseMatch, Resolver404
File "/usr/local/lib/python3.5/dist-packages/django/urls/exceptions.py", line 1, in
from django.http import Http404
File "/usr/local/lib/python3.5/dist-packages/django/http/__init__.py", line 2, in
from django.http.request import (
File "/usr/local/lib/python3.5/dist-packages/django/http/request.py", line 10, in
from django.core import signing
File "/usr/local/lib/python3.5/dist-packages/django/core/signing.py", line 45, in
from django.utils.crypto import constant_time_compare, salted_hmac
File "/usr/local/lib/python3.5/dist-packages/django/utils/crypto.py", line 6, in
import secrets
ImportError: No module named 'secrets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "manage.py", line 15, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 370, in execute
parser = self.fetch_command('runserver').create_parser('django', 'runserver')
File "/usr/local/lib/python3.5/dist-packages/django/core/management/
_init__.py", line 244, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 37, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 665, in exec_module
File "", line 222, in _call_with_frames_removed
File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 10, in
from django.core.servers.basehttp import (
File "/usr/local/lib/python3.5/dist-packages/django/core/servers/basehttp.py", line 17, in
from django.core.handlers.wsgi import LimitedStream
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/wsgi.py", line 6, in
from django.core.handlers import base
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 8, in
from django.urls import get_resolver, set_urlconf
File "/usr/local/lib/python3.5/dist-packages/django/urls/
_init__.py", line 1, in
from .base import (
File "/usr/local/lib/python3.5/dist-packages/django/urls/base.py", line 9, in
from .exceptions import NoReverseMatch, Resolver404
File "/usr/local/lib/python3.5/dist-packages/django/urls/exceptions.py", line 1, in
from django.http import Http404
File "/usr/local/lib/python3.5/dist-packages/django/http/__init__.py", line 2, in
from django.http.request import (
File "/usr/local/lib/python3.5/dist-packages/django/http/request.py", line 10, in
from django.core import signing
File "/usr/local/lib/python3.5/dist-packages/django/core/signing.py", line 45, in
from django.utils.crypto import constant_time_compare, salted_hmac
File "/usr/local/lib/python3.5/dist-packages/django/utils/crypto.py", line 6, in
import secrets
ImportError: No module named 'secrets'

2个回答

你没有安装secrets这个库,win+r 后输入cmd打开命令行工具然后输入pip install secrets 就行了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问