Home > other >  ModuleNotFoundError: No module named 'django_heroku' even after installation
ModuleNotFoundError: No module named 'django_heroku' even after installation

Time:09-08

I set up a Django project in a venv and installed django_heroku in the root folder of my project. When I run 'python manage.py runserver' I get the following error:

../settings.py", line 15, in <module>
import django_heroku
ModuleNotFoundError: No module named 'django_heroku'

This is my requirements.txt, all of these are installed:

asgiref==3.5.2
dj-database-url==1.0.0
Django==4.1
django-extensions==3.2.0
django-heroku==0.3.1
gunicorn==20.1.0
psycopg2==2.9.3
psycopg2-binary==2.9.3
python-dateutil==2.8.2
six==1.16.0
sqlparse==0.4.2
whitenoise==6.2.0

Relevant parts of settings.py:

import os
import django_heroku
...
ALLOWED_HOSTS = ['*']
...
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
django_heroku.settings(locals())

This is my Procfile:

web: gunicorn twatsite.wsgi

I have also tried moving the files in Twatter/twatsite/twatsite/.. one folder higher to Twatter/twatsite/.. This did not work and I moved the files back. Any pointers on how to solve or troublehsoot this issue are very welcome.

CodePudding user response:

The answer is that I was in a venv inside a venv. So a virtual environment inside another virtual environment.

(Twatter) (base) name@laptop twatsite %

I deleted my venv folder and exited the venv's I was in by doing 'deactivate' followed by 'conda deactivate' (because it told me to). After this I created a new venv folder within Twatter/ with 'python3 -m venv twatvenv' and activated it again with 'source twatvenv/bin/activate'.

After this I reinstalled the requirements with:

pip install -r twatsite/requirements.txt

Now I could run the server from Twatter/twatsite/ with 'python manage.py runserver'!

  • Related