Using poetry, django, postgres.
Django app deploys. App is fully functional.
However, commands inside the ssh console that require supposedly installed poetry apps fail.
Specifically, this issue is regarding the “poetry run python manage.py createsuperuser” command, a command that creates a super user for the app.
$ fly ssh console
...
# cd app
# ls
Dockerfile Ration_Django_Web_App manage.py media poetry.lock pyproject.toml ration readme.md static templatetags
poetry run python manage.py createsuperuser
Creating virtualenv ration-django-web-app-9TtSrW0h-py3.11 in /.cache/pypoetry/virtualenvs
Traceback (most recent call last):
File "/app/manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/manage.py", line 22, in <module>
main()
File "/app/manage.py", line 13, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
# python manage.py createsuperuser
Traceback (most recent call last):
File "/app/manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/manage.py", line 22, in <module>
main()
File "/app/manage.py", line 13, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
# which python
/usr/local/bin/python
I was able to navigate this issue by creating a user and modifying them to superuser through the postgres shell, but any explanation as to why this basic command isn’t working?