ModuleNotFoundError: No module named 'dj_rest_auth'
ModuleNotFoundError: No module named 'dj_rest_auth'
我不明白为什么我会遇到这个问题我按照安装指南中的大部分步骤操作: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'
settings.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',
]
Pip文件
[[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"
编辑:这个 repo 在 github 上,所以我重新克隆它并尝试了,但同样的错误。
编辑:我错了,这是因为我在安装 dj_auth_rest
时不在 pipenv shell
环境中
旧的错误答案:
我的 Anaconda 以某种方式导致了这个问题。
我用 conda deactivate
解决了这个问题。
我不明白为什么我会遇到这个问题我按照安装指南中的大部分步骤操作: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'
settings.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',
]
Pip文件
[[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"
编辑:这个 repo 在 github 上,所以我重新克隆它并尝试了,但同样的错误。
编辑:我错了,这是因为我在安装 dj_auth_rest
pipenv shell
环境中
旧的错误答案:
我的 Anaconda 以某种方式导致了这个问题。
我用 conda deactivate
解决了这个问题。