I’m trying to run a Django app on an Ubuntu VM but when I execute python manage.py runserver
I get this error message:
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?
The code is de default of a Django project, ie,
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise 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?"
) from exc
I’ve tried with all of the things described in this post (ie, I’m in a venv reciently created with django installed, checked the django installation, verified that PYTHONPATH is pointing to venv/lib/python3.8/site-packages
, etc.) but I still have the error. Any idea?
2
Answers
I've tried installing Django with:
and it worked.
Can you run command pip list to check Django is installed?
if is installed uninstall
pip uninstall Django
and then use this command to install again
python -c "import django"
and try again with new project