1

I started my django project without activating my virtualenv django-admin startproject my_project and django-admin startapp my_app. Everythiing went fine, till i closed my terminal, and stopped the serveer. I wanted to restart my server, but this message is still coming up. i tried to install the virtualenv still the same problem,

File "./manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
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?

Please what could be the problem and how to fix this ??

Patcho
  • 77
  • 8
  • is Django an importable module? Sounds like the current scope cant find it, which means you might need to install it by way of `pip install django` – Fallenreaper Jul 15 '17 at 16:46
  • Requirement already satisfied: django in ./myshop/myshop/lib/python2.7/site-packages Requirement already satisfied: pytz in ./myshop/myshop/lib/python2.7/site-packages (from django) – Patcho Jul 15 '17 at 16:50
  • check if its available in your env. `./manage.py shell` -> `import django` That should send an error like `ImportError: No module named django`. Are you sure you are in the same env as before? Its quite easy to navigate in the wrong path especially if you are not familiar with the terminal – hansTheFranz Jul 15 '17 at 16:58
  • indeed it's ouputting Non module named django. Actually i ddint activate the virtualenv beforestarting my project, just went stratight with the django-admin startproject my_project and django-admin startproject my_app – Patcho Jul 15 '17 at 17:01
  • yes in this case navigate the correct path start the env with `source env/bin/activate` and `pip install -e django/` – hansTheFranz Jul 15 '17 at 17:06
  • did all these then whem im trying to run djang-admin runserver, i got this . django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. – Patcho Jul 15 '17 at 17:17
  • @Patcho please use "@hanstheFranz" or I won't see you wrote something and can't help you. Yes you need a settings file. But this should be provided. Try to run `./manage.py runserver`. If you don't have a project yet you need to start one with `django-admin startproject myproject`. If you have one go into main folder and look for the settings.py file. maybe this helps you? https://stackoverflow.com/questions/15556499/django-db-settings-improperly-configured-error – hansTheFranz Jul 15 '17 at 17:53

1 Answers1

0

You should run pip install django at terminal after active the virtualenv.

williezh
  • 917
  • 5
  • 8
  • Hi, Thanks all. I fixed it. just needed to create a new virtual env, then install djnago and restart the old project. Anyway, i end up creating a docker image for my project.. – Patcho Jul 18 '17 at 08:24