3
votes

i am new in python learning.after learning python basics i have moved to learn python web framework Django. for this


i followed these steps for installing django on my windows after installing python 3.7

  1. first i opens cmd command prompt (C:\users\mypcname)
  2. then i created virtual environment wrapper with command pip install virtualenvironmentwrapper-win
  3. then i created virtual environment with command mkvirtualenv test
  4. then i entered command workon test to enable virtual environment
  5. then tried to install django with command pip install django and its successfully installed
  6. then i created projects directory with command mkdir djangoprojects
  7. then i created app directory in djangoprojects(which i created in last step) with command django-admin startproject firstproject
  8. then i moved to firstproject with command cd..
  9. there i tried to run server with command python manage.py runserver and got error

Traceback (most recent call last): File "manage.py", line 10, 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 "manage.py", line 21, in main() File "manage.py", line 12, 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?


can anyone guide me what i have done here wrong ? why its showing error

1
check if you installed django in the environment. To do that activate the environment and call pip freeze. - tstoev
@t.stv i tried to check by going to environment workon test then i typed django-admin --version its showing django version 3.0.5 means its installed in environment (but when i check its version outside the environment its showing version there too means its installed there too). what is freez ? - barbiequeen
@t.stv (test) C:\Users\dewams-junaidpc>pip freeze appdirs==1.4.3 asgiref==3.2.7 distlib==0.3.0 Django==3.0.5 filelock==3.0.12 pytz==2019.3 six==1.14.0 sqlparse==0.3.1 virtualenv==20.0.18 virtualenvwrapper-win==1.2.6 - barbiequeen
looks ok, check your pythonpath in evironment variables - tstoev
there is only 1 env variable test which i am using - barbiequeen

1 Answers

0
votes

i got solution by myself. actually i had downloaded python twice with different versions also i had downloaded python with anaconda package. i uninstalled all python versions and anaconda from my computer then i reinstalled python from his official website. then i tried above method which works fine.thanks to myself