Import error: No module named 'secrets' - python manage.py not working after pull to Digital Ocean

Import error: No module named 'secrets' - python manage.py not working after pull to Digital Ocean

我正在学习一门课程 - Django 开发到部署。
将它拉到 Digital Ocean 后,其他一切 运行 都很顺利。直到
我试过了 运行 python manage.py help

(env) djangoadmin@ubuntu-1:~/pyapps/btre_project_4$ python manage.py help

我收到这个错误。

Traceback (most recent call last):


File "manage.py", line 21, in <module>
    main()
   File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/__init__.py", line 16, in setup
    from django.urls import set_script_prefix
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/urls/__init__.py", line 1, in <module>
    from .base import (
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/urls/base.py", line 9, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/urls/exceptions.py", line 1, in <module>
    from django.http import Http404
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/http/__init__.py", line 2, in <module>
    from django.http.request import (
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/http/request.py", line 10, in <module>
    from django.core import signing
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/core/signing.py", line 45, in <module>
    from django.utils.crypto import constant_time_compare, salted_hmac
  File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/utils/crypto.py", line 6, in <module>
    import secrets
ImportError: No module named 'secrets'

我是一个新手,已经坚持了一段时间。我只想知道这可能是什么原因造成的。

secrets 模块已添加到 3.6 版的 Python 中。您的主机正在使用 Python 3.5,因此机密模块不可用。您需要一个 Python 3.6+ 的主机,或者不依赖于 secrets 模块的 Django 版本

有同样的问题,通过指定我安装的 python 版本解决了它。即

$ python3
>>> import secrets
>>> secrets.token_hex(16)