If you are currently using a windows operating system, the follow the steps to install Python on Windows.
Where to download?
Always download from a reputable source
https://www.python.org/downloads/
Which version?
We are going to use version three of python. It is going to get most of the future updates with version 2 only getting bug fixes.
At the time of writing version 3.5.2 is the latest. So install it. I always try to install the MSI version.
If offered an option to install for all users or just the current user. Install for all users.
Accept the default file location. I was given c:\users\mark\appdata\local\programs\python\python35-32
If given an option to add python exe to the path say yes. This will make your life a lot easier.
Start Up A Windows Command Prompt
Command prompt is the interface to issue type commands to windows. It should be under Accessories in your Windows start menu or just press Windows Key + R cmd <enter>
Check The Version Number Command Prompt
Type in python at the command prompt and look at the output. Make sure it gives the version number you downloaded.
At the python prompt type in
print Hello World
and check the output
Type in
quit()
To get out python and go back to the command prompt
Upgrade pip with
Pip install --upgrade pip
I get an error message as well as I success message, but the upgrade works.Pip is the preferred program it use to download python components. But we upgrade because recent versions offers much better performance.
Create a project directory
Mkdir testproj
Cd testproj
This is where our code would go
Make a test project with virtualenv
Install virtualenv
Pip install virtualenv
We use virtualenv to keep our list of requirements for the different versions of our requirements seperate. We are going to test downloading requirements to make sure everything is set up correctly.
Virtualenv
Builds the virtualenv. This is just a set of directories that python puts special versions of everything in.
Type in at the command line
Scripts\activate
This activates your virtualenv meaning with python will use libraries and modules inside of it.
Do a dir to see the list of directories it has created.
Once set up we need to activate the virtualenv which means we will use the versions of libraries in it by default. The (testproj) is the name of the virtualenv that we have activated.
Example with numpy
We are going to use an example from numpy to check that everything is set up correctly.
First download numpy with pip
Pip install numpy
At the Windows Command prompt make sure you have activated the virtualenv.
Next start up python. Type at the command prompt
Python
Then at the python console
import numpy as np
a = np.array([1, 2, 3]) # Create a rank 1 array
print (type(a)) # Prints "<type 'numpy.ndarray'>"
print (a.shape) # Prints "(3,)"
print (a[0], a[1], a[2]) # Prints "1 2 3"
a[0] = 5 # Change an element of the array
print (a) # Prints "[5, 2, 3]"
b = np.array([[1,2,3],[4,5,6]]) # Create a rank 2 array
print (b.shape) # Prints "(2, 3)"
print (b[0, 0], b[0, 1], b[1, 0]) # Prints "1 2 4"
If the output matches the comment numpy works correctly.