0

I have been struggling to get Django up and running. I used pip to install Django version 1.10.4 and I have been following the tutorial for the poll app. However, when I get to the

manage.py runserver

step, I get the following error:

"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"

Paths = zip, DLLS, lib, Python 3.5, lib\site-packages

django-admin is in Scripts, however I copied the exe to Python 3.5, which is the dir I ran:

django-admin startproject mysite

I ran the runserver command from Python3.5\mysite which contains manage.py

Honestly, I didn't use virtualenv because I just wanted to get up and running and I thought bypassing that step (for myself) would be the best route, but neither has worked. hah.

:Python 3.5.2\Scripts> pip install django
Collecting Django
Using cached Django-1.-10-4-py2.py3-none-any.whl
Successfully installed django-1.10.4

:Python 3.5.2\Scripts> django-admin startproject mysite
:Python 3.5.2\Scipts

Scripts is the only dir these commands work.

:Python 3.5.2\Scripts\mysite> manage.py runserver
"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?

Django dir and Django-1.10.4.distinfo is in Lib\site-packages and the django-admin files are in the Scripts dir...Even if I copy djano-admin.exe to one of the PYTHONPATHs, I have the same issues.

I have python 2.7x and python 3.5.2 installed, on two separate drives, but have not run into any other issues.

verase
  • 1
  • 1
  • 2
  • I am NOT using virtualenv – verase Dec 07 '16 at 00:26
  • Apparently something is wrong with your Python installation. Try `pip install django` again, and after that finishes, try `python manage.py runserver`. Then, if the problem persists, show the exact and full output of both commands. Also, is this the only Python you have installed on your system? – Antonis Christofides Dec 07 '16 at 08:13
  • @AntonisChristofides I tried what you mentioned but didn't have any luck. I updated the question with the additional information – verase Dec 08 '16 at 18:34
  • 1
    Should be `python manage.py runserver`, not just `manage.py runserver`. Scripts is a bad directory to put your projects. – Antonis Christofides Dec 08 '16 at 19:56

3 Answers3

1

This could possibly happen if we are not invoking the right version of PIP. In case you have 2 versions of Python and you want to install over Python 3.4, you need to select pip3 from the absolute path, just in case if there is something else that could precede in the environment variables.

The simplest way is to select the right version of pip from the absolute path as below:

C:\Python34\Scripts>pip3 install django
Tonechas
  • 11,520
  • 14
  • 37
  • 68
Kenny
  • 9
  • 2
0

Maybe command line "python manage.py runserver" can start it.I meet the same question,though I configured the PATH environment. enter image description here

0

If you used window 10 for Django Framework then you can follow these steps maybe it helps for you

Pip install virtualenvwrapper-win
Mkvirtualenv test
Pip install django
Mkdir projects
Django-admin startproject project_name
Python manage.py runserver

I am very new in python and Django I follow the above steps for setup the env and startup the first project.

The above first command create the virtual Wrapper for you and the second command will create the virtual env inside the Wrapper. Then we have to install the django inside the venv. These virtul env is not accessable to new command prompt.

Suppose next time when you want to work on the same venv you need to type

Workon test

In my case test is env name. so it will open you vevn.

May be it will help for you or who are new in python.

Anupam Choudhary
  • 29
  • 1
  • 1
  • 9