How to Install Python & Django on Windows

Install Python, Virtual Environments, Django on Windows Using PIP (Python Package Installer) and Windows Powershell We can setup python virtual environments and Django on windows PC.

1. Download from Lates python version for windows from that url. https://www.python.org/downloads/

2. Run python .exe installable  file and install python.
3. Verify Python Installed in Powershell    

    1. Search/Open Windows Powershell
    2. Type 
      1
      python -V

       and hit enter. Does the following show up?:

    3. Verify pip by entering:    pip freeze

4. Update Powershell Settings:

You should only have to do this 1 time, if done correctly. 1. Search Windows Powershell (a search is important) 2. Right click, select “Run as Administrator”; cofirm security pop-up if needed 3. Enter:

1
Set-ExecutionPolicy Unrestricted

5. Create Dev Folder (directory):

Open Windows Powershell (not needed to run as Admin now)
Type:

1
2
C:\ > cd ~/
C:\ > mkdir Dev

6. Install Virtualenv:

Going forward, whenever you see > or $ before code, that means you should be working in the Windows Powershell (or Command Prompt if you don’t have Windows Powershell)

To install a virtual environment:

1
 pip install virtualenv

Verify:

1
 pip freeze

virtualenv==15.1.0

6. Create a Virtualenv:

Navigate to Dev:

1
 > cd ~/Dev

Make virtualenv parent directory:

1
2
3
4
 > mkdir cfehome
&gt; cd cfehome <code>
Create virtualenv
<code> &gt; virtualenv .

Note, if you have two versions of python installed you may have to do this:

1
 &gt; virtualenv -p python3 .

Activate your environment:

1
2
3
&gt; cd \path\to\your\virtualen\env\
&gt; cd ~\Dev\cfehome
&gt; .\Scripts\activate

6.Now install any Python Package:

1
2
3
&gt; cd ~\Dev\cfehome
&gt; .\Scripts\activate
(cfehome) &gt; pip install django==1.11.5

7.Now run python django on server:

1
2
3
4
mkdir src
cd src
django-admin.py startproject cfehome .
python manage.py runserver

Now check server url in browser .