ModuleNotFoundError:没有名为“dj_rest_auth”的模块

问题描述 投票:0回答:2

我不明白为什么会遇到这个问题,我按照指南中的大部分步骤进行安装:https://dj-rest-auth.readthedocs.io/en/latest/installation.html
除了我用过

pipenv install

但是,
python manage.py migrate
给了我这个错误:

    main()
  File "/home/ryan/Documents/is4103/is4103-capstone-id01/Backend/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/ryan/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/home/ryan/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute
    django.setup()
  File "/home/ryan/.local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/ryan/.local/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/home/ryan/.local/lib/python3.9/site-packages/django/apps/config.py", line 223, in create
    import_module(entry)
  File "/usr/local/lib/python3.9/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 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'dj_rest_auth'

设置.py

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'BackendApp',
    'rest_framework',
    'rest_framework.authtoken',
    'dj_rest_auth',
]

Pipfile

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = "*"
django = "*"
psycopg2-binary = "*"
django-polymorphic = "*"
pillow = "*"
djangorestframework = "*"
markdown = "*"
django-filter = "*"
dj-rest-auth = "*"

[dev-packages]

[requires]
python_version = "3.9"

编辑:这个存储库位于 github 上,所以我重新克隆它并尝试,但出现同样的错误。

python django conda pipenv pipenv-install
2个回答
1
投票

编辑:我错了,因为我安装时不在

pipenv shell
环境中
dj_auth_rest

旧的错误答案:

我的 Anaconda 不知何故导致了这个问题。

我用

conda deactivate
来解决这个问题。


0
投票

您可以通过安装软件包来解决此问题

dj_rest_auth

pip install dj_rest_auth
© www.soinside.com 2019 - 2024. All rights reserved.