pywin

There are two different, incompatible versions of Python in general use around the world — Python 2.7 and Python 3.4. Significant changes to the Python language were made between Python 2.x and Python 3.y (for all values of x and y). The Python 3 language is cleaner, more self-consistent, and more user-friendly. Programs written for versions of Python 2 will not necessarily run on Python 3 installations; if they do run, they may get different answers to the same problem.

 There are two variants of Python 3.4 for Windows — a 32-bit version and a 64-bit version. Obviously, the 64-bit version requires a 64-bit Windows computer. Fortunately, most Windows PCs sold over the past few years are 64-bit. However, the 32-bit version of Python can run on both 64-bit Windows PCs and 32-bit Windows PCs.

For getting started, we must use the 32-bit version of Python on Windows. The reason is that the official release of numpy is currently available for Windows only in 32-bit format.

To obtain the correct version of Python, click on this link —  python-3.4.0.msi— and download the resulting file to a convenient folder or directory. Alternatively, you may browse to — https://www.python.org/ftp/python/3.4.0/python-3.4.0.msi — and download them from there.

Note: If you go to an official Python download page, you will find a downloadable file named python-3.4.0.amd64.msi. Do not install this! It is the 64-bit version, and it is not compatible with the currently available version of numpy.

Double-click on the file python-3.4.0.msi to start the installation. You should be greeted by a dialog box resembling the following:–

080416_1030_1.png

If you subsequently see a dialog box resembling Figure 2 below for any version of Python 3, select Remove Python for that version.

This is important. There may already be a 64-bit Python installed without your knowing it, and this will cause problems with the installation of numpy and matplotlib.

Removing Python will take several minutes and may require you to confirm in one or more additional dialog boxes.

image004

After you have removed your previous version of Python, click Finish and start over at Figure 1. After clicking Next, you should see a dialog box resembling the following:–

080416_1030_3.png

Whether you choose to install “for all users” or just for yourself is a matter of personal preference. Click Next to bring up the following dialog box.

Click Next to select the default directory. If it tells you the directory already exists and asks if you are sure that you want to overwrite existing files, click Yes. In the next dialog box (Figure 5 below), you may customize the installation. Simply click Next without making any changes.

The installation should begin and will take several minutes and may require confirmation in additional dialog boxes.[3] When it completes, you should see the final dialog box, below.

Click Finish to complete the installation of Python 3.4.1.

Testing your installation on Windows 7

If you are running Windows 7, you may confirm your installation by clicking the Start button to bring up the Windows Start menu. Select All Programs and scroll down to Python 3.4. Open this folder to expose the following shortcuts:–

Click on IDLE (Python GUI) to bring up the following window (only the upper part of which is shown here):–

image015

This is IDLE, the Python command prompt and graphical user interface. This is where we will start all programs and projects in this course. For now, simply type any Python statement or expression after the “>>>” prompt. For example, in Figure 8, the expression 2 + 3 + 4 was typed and Python responded with the value 9. Continue testing by typing out the code on pages 10-11 of the textbook, just to make sure that your installation works as expected.

Installing matplotlib, numpy, and other packages

One of the many benefits of Python is the vast number of third-party packages that can be downloaded and used by your Python programs. Many of these are open-source and free. For this course, we will use at least the following:–

  • matplotlib (a package for creating 2D plots and graphs similar to Matlab),
  • numpy (meaning “Numerical Python,” a package for efficient handling of large arrays of numerical data), and
  • py, a simple tool written in Python 3 and created by the textbook author for making simple drawings.

Installing Graphics.py                      

To install graphics.py, click on this link — graphics.py — and download the file to the folder where you keep your Python programs. Follow the instructions on p.488 of the textbook.

Installing numpy 1.8.1

In either Windows 7 or Windows 8, click on the following link — http://jaist.dl.sourceforge.net/project/numpy/NumPy/1.9.2/numpy-1.9.2-win32-superpack-python3.4.exe

— to download the numpy installer. Open this to begin the installation. After confirming that you do want to allow the system to install software, it will start the installation and show the following dialog box:–

image018

Click Next. If your installation of Python 3.4 is correct, you should get the following dialog:–

image019

If instead, it complains that you do not have Python 3.4 installed, ask for help. Such a complaint could arise if Python was not correctly installed or if you have the 64-bit version.

After the installation completes, click Finish. Note that you might have to click somewhere in some window to get the Finish dialog box to pop up. Note also that this installer contains all of the dependencies of numpy — i.e., other packages needed by numpy to run. They are installed silently.

You can test your installation of numpy by opening an IDLE window, as in Figure 8. Type or paste the following commands into IDLE, one line at a time, exactly as written:–

import numpy as np

np.__version__ [4]

a = np.arange(10)
a

b = np.arange(1, 9, 2)
b

c = np.eye(3)
c

d = np.diag(np.array([1, 2, 3, 4]))
d

The result should resemble the following figure:–

080416_1032_SettingupPy11.png

Congratulations! You have now installed a working versions numpy 1.8.1.

Installing Matplotlib on Windows[5]

Installing Matplotlib is not nearly so straightforward. There is no “officially released” installer that captures all of the dependencies. The only installer that the Professor could find at the time of this writing is an “unofficial” one that contains just Matplotlib itself. Therefore, you need to download and manually install each of the packages upon which Matplotlib depends.

Download and open Windows/matplotlib-1.3.1.win32-py3.4.exe. The installer will open two dialog boxes similar to but not identical to Figure 11 and Figure 12. Allow the installation to run to completion.

Next, download and run the installers for each of the following packages:–

These should all install uneventfully, again with dialog boxes resembling Figure 11 and Figure 12.

To test your matplotlib installation, type or paste the following commands into IDLE, one line at a time, exactly as written:–

from matplotlib import pyplot
pyplot.plot([1, 2, 3, 4], [1, 4, 9, 16])
pyplot.show()

The IDLE window should look something like the following:–

080416_1032_SettingupPy12.png

After you type the ENTER key following the last line, the following window should appear:–

080416_1032_SettingupPy13.png

To close this window, click on the “close” button in the upper right.

Congratulations! You now have a working version of matplotlib installed.


Installing SciPy 0.16.1

In either Windows 7 or Windows 8, click on the following link —— http://ncu.dl.sourceforge.net/project/scipy/scipy/0.16.1/scipy-0.16.1-win32-superpack-python3.4.exe

 

to download the scipy installer. Open this to begin the installation. After confirming that you do want to allow the system to install software, it will start the installation and show the following dialog box:–

 

image018

Click Next. If your installation of Python 3.4 is correct, you should get the following dialog:–

image019

If instead, it complains that you do not have Python 3.4 installed, ask for help. Such a complaint could arise if Python was not correctly installed or if you have the 64-bit version.

After the installation completes, click Finish. Note that you might have to click somewhere in some window to get the Finish dialog box to pop up. Note also that this installer contains all of the dependencies of scipy — i.e., other packages needed by scipy to run. They are installed silently.

Reference: http://web.cs.wpi.edu/~cs1004/a14/Resources/

Advertisements