I added the Django-rest-Knox into the requirement.txt then ran the "docker-compose up" command in my terminal. But, I got this error message "ModuleNotFoundError: No module named 'Knox'". Any idea, why is that?
I added the Django-rest-Knox into the requirement.txt then ran the "docker-compose up" command in my terminal. But, I got this error message "ModuleNotFoundError: No module named 'Knox'". Any idea, why is that?
You need to install Knox module for Django. Use this command to do it:
pip install -U django-rest-knox
I ran into the same problem and realized that I installed Django-rest-knox under virtual environment.
I have run the code
pip install -U django-rest-knox
But still I am getting the same error
(.venv) shayid@Abus-MacBook-Air CS5942-Bravo-2022 % pip install django-rest-knox
Requirement already satisfied: django-rest-knox in
/usr/local/lib/python3.9/site-packages (4.2.0)
Requirement already satisfied: cryptography in
/usr/local/lib/python3.9/site-packages (from django-rest-knox) (37.0.4)
Requirement already satisfied: django>=3.2 in
/usr/local/lib/python3.9/site-packages (from django-rest-knox) (4.0.6)
Requirement already satisfied: djangorestframework in
/usr/local/lib/python3.9/site-packages (from django-rest-knox) (3.13.1)
Requirement already satisfied: sqlparse>=0.2.2 in
/usr/local/lib/python3.9/site-packages (from django>=3.2->django-rest-
knox) (0.4.2)
Requirement already satisfied: asgiref<4,>=3.4.1 in
/usr/local/lib/python3.9/site-packages (from django>=3.2->django-rest-
knox) (3.5.2)
Requirement already satisfied: cffi>=1.12 in
/usr/local/lib/python3.9/site-packages (from cryptography->django-rest-
knox) (1.15.1)
Requirement already satisfied: pytz in /usr/local/lib/python3.9/site-
packages (from djangorestframework->django-rest-knox) (2022.1)
Requirement already satisfied: pycparser in
/usr/local/lib/python3.9/site-packages (from cffi>=1.12->cryptography-
>django-rest-knox) (2.21)
(.venv) shayid@Abus-MacBook-Air CS5942-Bravo-2022 % python3 manage.py
migrate
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/shayid/Library/Python/3.8/lib/python/site-
packages/django/core/management/__init__.py", line 446, in
execute_from_command_line
utility.execute()
File "/Users/shayid/Library/Python/3.8/lib/python/site-
packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/Users/shayid/Library/Python/3.8/lib/python/site-
packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/shayid/Library/Python/3.8/lib/python/site-
packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/Users/shayid/Library/Python/3.8/lib/python/site-
packages/django/apps/config.py", line 228, in create
import_module(entry)
File
Library/Developer/CommandLineTools/Library/Frameworks/
Python3.framework/Ve
rsions/3.8/lib/python3.8/importlib/__init__.py", line 127, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in
_find_and_load_unlocked
ModuleNotFoundError: No module named 'knox'