Friday, September 7, 2012

DOWNLOADING AND INSTALLING, PYTHON 2.7.8

DOWNLOADING AND INSTALLING, PYTHON 2.7.8



REVISED: Sunday, June 7, 2015




In this tutorial, you will learn how to download  and install, Python 2.7.8.

I.  PYTHON INTRODUCTION

Python is free to use; even for commercial products!

Python is an easy to learn, powerful programming language. Python’s elegant syntax and dynamic typing, make it an ideal language for scripting and rapid application development. Python is an interpreted language, which can save you considerable time during program development because no compilation and linking are necessary. And, as proof that Python was created to be fun, Python was named after the British Broadcasting Corporation (BBC) show “Monty Python’s Flying Circus!"

II. DOWNLOADING AND INSTALLING PYTHON

To download Python click on the following link:

 PYTHON.

Select the appropriate download for your computer; and during the download, select the option which places a Python icon on your desktop. You will then be able to "double left mouse click" the Python icon as a shortcut when you want to start the Python interpreter shell.

My computer uses Microsoft Windows; therefore, I used the "Windows Installer" for Python 2.7.8 and my Python download was to the following default hard drive path folder:
C:\Python27\

If necessary, check your hard drive and write down and remember the hard drive default path folder your computer used for your Python download.  You will need to know this default information when you are writing and reading Python files.

III.  PYTHON DOWNLOAD AND INSTALLATION VAIDATION

"Double left mouse click" the Python icon on your desktop to start the Python interpreter shell. A Python interpreter shell window will open, as shown below:

Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 

When you see the above message, you have successfully downloaded and installed Python.

IV. DOWNLOADING AND INSTALLING NumPy

NumPy is a software package for scientific computing in Python.

To download NumPy click on the following link:

 NumPy.

Select the appropriate download for your computer.

I selected Download numpy-1.6.2-win32-superpack-python2.7.exe (5.7 MB) and used all of the download defaults.

After the download and installation is complete, "double left mouse click" the Python icon on your desktop to start the Python interpreter shell. When the Python interpreter shell window will opens, type the NumPy import and code as shown below:
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>import numpy as np
#Imports NumPy.
>>>np.arange(10) #NumPy creates an array with 0 thru 9 elements
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>>


When you see array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), you have successfully downloaded and installed NumPy.

V. DOWNLOADING AND INSTALLING SciPy

SciPy is the scientific algorithms package. SciPy is a software package for mathematics, science, and engineering computing in Python.

To download SciPy click on the following link:

 SciPy.

Select the appropriate download for your computer.

I selected Download scipy-0.11.0rc2-win32-superpack-python2.7.exe (47.9 MB) and used all of the download defaults.

After the download and installation is complete, "double left mouse click" the Python icon on your desktop to start the Python interpreter shell. When the Python interpreter shell window will opens, type the SciPy import and code as shown below:
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>import scipy as sp
#Imports SciPy.
>>>from scipy import linalg #SciPy imports the linear algebra sub package.

#Solving a linear system.
#x+3y+5z=10
#2x+5y+z=8
#2x+3y+8z=3
>>>A = sp.mat('[1 3 5; 2 5 1; 2 3 8]') #Input matrix.
>>>b = sp.mat('[10;8;3]') #Right hand side vector.
>>>A.I*b #Inverse of A multiplied by b.
#Solution vector is shown below.
matrix([[-9.28],
              [ 5.16],
              [ 0.76]])
>>>

When you see the solution vector, at the bottom, as shown above, you have successfully downloaded and installed SciPy.

VI. DOWNLOADING AND INSTALLING matplotlib

matplotlib is a plotting library for the Python programming language and its NumPy numerical mathematics extension. matplotlib is the whole package; PyLab is a module in matplotlib that gets installed alongside matplotlib; and matplotlib.pyplot is a module in matplotlib.

To download matplotlib click on the following link:

 matplotlib.

Select the appropriate download for your computer.

I selected Download matplotlib-1.1.0.win32-py2.7.exe (4.2 MB) and used all of the download defaults.

After the download and installation is complete, "double left mouse click" the Python icon on your desktop. When the "Python Shell" window opens select "File", then select "New Window". In the "New Window" type the following code. Use four spaces, columns, for each indent.

import math
import pylab # matplotlib
# create the x list data
# arange( ) is like range( ) but allows float numbers
x_list = pylab.arange(0.0, 5.0, 0.01)
# calculate the y list data
y_list = [ ]
for x in x_list:
      y = math.cos(2*math.pi*x) * math.exp(-x)
      y_list.append(y)
pylab.xlabel("x")
pylab.ylabel("cos(2pi * x) * exp(-x)")
# draw the plot with a blue line 'b' (is default)
# using x,y data from the x_list and y_list
#
# other drawing styles -->
# 'r' red line, 'g' green line, 'y' yellow line
# 'ro' red dots as markers, 'r.' smaller red dots, 'r+' red pluses
# 'r--' red dashed line, 'g^' green triangles, 'bs' blue squares
# 'rp' red pentagons
#
pylab.plot(x_list, y_list, 'y')
# save the plot as a PNG image file (optional)
pylab.savefig('matplotlibTest.png')
# show the pylab plot window
# you can zoom the graph, drag the graph, change the margins, save the graph
pylab.show( )

From the "New Window", do a "File Save As" and save the above Python program, using the file name matplotlibTest.py to the same path which your computer used to download Python 2.7.3. For example, I saved my matplotlibTest.py  file  to my Python27 folder using the following path:

C:\Python27\matplotlibTest.py

From the "New Window", do a "Run" and then a "Run Module F5" and a graph with the title "matplotlibTest" in the top left corner will open.

When you see the matplotlibTest graph, you have successfully downloaded and installed matplotlib.

VII. DOWNLOADING AND INSTALLING PyOpenGL

PyOpenGL produces 2D and 3D computer graphics and supports the GL, GLU, GLE, and GLUT libraries.

To download PyOpenGL click on the following link: 

 PyOpenGL.

Select the appropriate download for your computer.

I selected Download PyOpenGL-3.0.1.win32.exe (1.1 MB) and used all of the download defaults.

After the download and installation is complete, "double left mouse click" the Python icon on your desktop. When the "Python Shell" window opens select "File", then select "New Window". In the "New Window" type the following code. Use four spaces, columns, for each indent.

from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *

import random

def initFun( ):
    glClearColor(1.0,1.0,1.0,0.0)
    glColor3f(0.0,0.0, 0.0)
    glPointSize(1.0)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluOrtho2D(0.0,640.0,0.0,480.0)
   
def displayFun( ):
    glClear(GL_COLOR_BUFFER_BIT)
    glBegin(GL_POINTS)

    x=[0.0,640.0,320.0]
    y=[0.0,0.0  ,480.0]

    curx=0
    cury=320
    glVertex2f(curx,cury)
    for i in range(0,500000):
        idx=random.randint(0,2)
        curx=(curx+x[idx])/2.0
        cury=(cury+y[idx])/2.0
        glVertex2f(curx,cury)
    glEnd( )
    glFlush( )

if __name__ == '__main__':
    glutInit( )
    glutInitWindowSize(640,480)
    glutCreateWindow("pyOpenGLTest")
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
    glutDisplayFunc(displayFun)
    initFun( )
    glutMainLoop( )

From the "New Window", do a "File Save As" and save the above Python program, using the file name pyOpenGLTest.py to the same path which your computer used to download Python 2.7.3. For example, I saved my pyOpenGLTest.py  file  to my Python27 folder using the following path:

C:\Python27\pyOpenGLTest.py

From the "New Window", do a "Run" and then a "Run Module F5" and a window with a triangle with the title "pyOpenGLTest" in the top left corner will open.

When you see the window with a triangle with the title "pyOpenGLTest" in the top left corner, you have successfully downloaded and installed pyOpenGL.

VIII. DOWNLOADING AND INSTALLING mpmath

mpmath is a pure-Python library for multiprecision floating-point arithmetic.

To download mpmath click on the following link: 

 mpmath.

Select the appropriate download for your computer.

I selected mpmath-0.17.win32.exe and used all of the download defaults.

After the download and installation is complete, "double left mouse click" the Python icon on your desktop. When the "Python Shell" window opens select "File", then select "New Window". In the "New Window" type the following code. Use four spaces, columns, for each indent.

from mpmath import *
mp.dps = 60
print "pi to 60 decimal places: "
print pi

From the "New Window", do a "File Save As" and save the above Python program, using the file name mpmathTest.py to the same path which your computer used to download Python 2.7.3. For example, I saved my mpmathTest.py  file  to my Python27 folder using the following path:

C:\Python27\mpmathTest.py

From the "New Window", do a "Run" and then a "Run Module F5" and the  "Python Shell" window will open.

When you see pi printed to 60 places on the "Python Shell" window, you have successfully downloaded and installed mpmath.

In this tutorial, you have learned how to download and install, Python 2.7.8.

Elcric Otto Circle




-->



-->



-->












How to Link to My Home Page

It will appear on your website as:

"Link to: ELCRIC OTTO CIRCLE's Home Page"