Skip to content

Commit

Permalink
Merge pull request presnick#80 from aerenchyma/add-install-ch
Browse files Browse the repository at this point in the history
Add install ch
  • Loading branch information
presnick committed Oct 3, 2014
2 parents e0d9d35 + 4c581d4 commit b298779
Show file tree
Hide file tree
Showing 35 changed files with 239 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/clone.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/clone2.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/directory.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/downloads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/environment.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/firstprog.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/fork.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/forkconfig.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/gitconfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/gitstatus1.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/gitstatus2.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/gitstatus3.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/gitstatus4.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/helloworld.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/pullupstream.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/secondprog1.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/secondprog2.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/tabs.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pip2/source/Installation/Figures/typedpython.png
Binary file added pip2/source/Installation/Figures/upstream.JPG
Binary file added pip2/source/Installation/Figures/upstream2.JPG
60 changes: 60 additions & 0 deletions pip2/source/Installation/NextSteps.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. Copyright (C) Brad Miller, David Ranum, Jeffrey Elkner, Peter Wentworth, Allen B. Downey, Chris
Meyers, Dario Mitchell, Paul Resnick. Permission is granted to copy, distribute
and/or modify this document under the terms of the GNU Free Documentation
License, Version 1.3 or any later version published by the Free Software
Foundation; with Invariant Sections being Forward, Prefaces, and
Contributor List, no Front-Cover Texts, and no Back-Cover Texts. A copy of
the license is included in the section entitled "GNU Free Documentation
License".
.. _next_steps:

Preparing for the Rest of the Course
====================================

It has been convenient to be able to execute python code right in the browser. To write and
execute bigger programs, to use modules beyond the few (like the ``random`` module) that have been implemented for this environment, and to perform file and network operations, you will need to run Python *natively* on your computer.

First, we'll provide an overview of how writing and running programs on your own computer works. Then we'll provide instructions for installing what you need and getting the new setup going.

There are different instructions for Windows users and Mac users below. (If you use Linux, there are no instructions for you -- we assume in that case you know what you are doing here, but if you are confused, let us know.)

None of the steps that follow is particularly difficult, but there are a lot of them, and if you inadvertently skip one, you may not have a good time. We recommend that you print out this chapter and use a pen to check off the steps as you do them, or do the equivalent on screen with a PDF file.

Important Concepts
==================

Up till now, we have written code in the active code windows and clicked "Run" to run it. You saw results in the console, below the active code windows-- remember, ``print`` is for people.

When you write code and run it *on your own computer*, what happens is basically this:

You'll write a program and save it as a file. You need a text editor to do this (more about this below! Note that MS Word is *not* a text editor).

.. note::

All programs you will write from here on will be stored in files (or groups of files, but we'll get to that) that are saved in a certain way, with the extension **.py**, so the computer knows these are *Python programs*.

You will have an interpreter for Python programs installed on your computer. Read on to find out how to do that. Naturally enough, that interpreter will be called ``python``.

You'll use the command prompt, which you've already been learning about, to essentially say "hey, python, find this file that has my Python program, and interpret and then run it." The analog of clicking on the "Run" button in our online environment will be to type ``python <your_code_file_name.py>`` at a command prompt. For example:

.. image:: Figures/secondprog1.JPG

You'll always have to know exactly where you saved your code file on your computer. Similar to how every single character matters when you write Python code, you have to tell the computer exactly where the program file you want to run is.

In summary, the biggest differences from the online environment you've been using will be that you'll switch back and forth between two windows (one for editing the code, another for running it), you will name all the code files you save, and it's very important how and where you save your files. This is where your file system and Unix knowledge from the past few weeks will help!

Preparing Your Computer for the Rest of the Course
==================================================

We will walk you through the process of setting up your computer to run Python natively. It will involve the following steps:

1. Install and configure a text editor

#. Install and configure Python

Then, you'll save your files in the folder/file structure we've been working with for the Unix Problems, so you have one folder where all of your code lives. **Make sure** to save all your code in this same place, where you can find it and know exactly where it all is -- not doing so will create a headache for you!

The instructions diverge a bit, depending on whether you are on Windows or a Mac. (If you're on
Linux, we presume that you know what you're doing already and can make appropriate
improvisations from the instructions for Windows or Mac, but feel free to ask.)
89 changes: 89 additions & 0 deletions pip2/source/Installation/TextEditor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. Copyright (C) Brad Miller, David Ranum, Jeffrey Elkner, Peter Wentworth, Allen B. Downey, Chris
Meyers, Dario Mitchell, Paul Resnick. Permission is granted to copy, distribute
and/or modify this document under the terms of the GNU Free Documentation
License, Version 1.3 or any later version published by the Free Software
Foundation; with Invariant Sections being Forward, Prefaces, and
Contributor List, no Front-Cover Texts, and no Back-Cover Texts. A copy of
the license is included in the section entitled "GNU Free Documentation
License".
.. _text_editor_installation:


Installing a Text Editor
========================

You will need a text editor. There are many options for this. For example, serious
programmers often use Eclipse or XCode, which are environments that include some useful tools, or Vim or Emacs, which are text editors that you can use inside the command prompt, which require learning a lot of keyboard commands. We do not recommend those for beginners programming -- better to focus on the problem-solving itself, and there's a lot of stuff to configure in those that you don't need right now. (Many serious programmers don't use those either!)

Definitely **do not** use MS Word. Word will not save files in the right format, so you will not be able to run programs, and it doesn't do any syntax highlighting or other useful things. Default programs that come with your operating system like TextEdit for Mac or plain Notepad for Windows are also not a good idea -- this can lead to file formatting issues, and you won't have syntax highlighting and other useful features.


.. _windows_install:

Windows Instructions
====================

The editor that we will help you to use is called **NotePad++**. Please download it from
`this site <http://notepad-plus-plus.org/download/>`_. Download it and then run the installer to install NotePad++, like you would most programs you download.

.. note::

Important! Before you create your first program, you need to make one small change in the Preferences for NotePad++. This will save you lots of "Python indent errors" anguish later.
Under *Settings -> Preferences -> Language Menu/Tab Settings*, tick the check box for "Expand Tabs", leaving the value at "4", and
press the "Close" button.

.. image:: Figures/tabs.JPG


Follow the instructions below. It should be
quite intuitive. The one thing to keep in mind is that NotePad++ is an environment
for *creating* python programs. It doesn't run them! You'll have to install a little
more stuff to run your programs, as described in later sections.
(If you'd like to see a demonstration of NotePad++, Dr. Chuck has a screen cast for the use of NotePad++.
You can either view this `on YouTube <http://www.youtube.com/watch?v=o0X-VHX6ls0>`_ or you can download the high-quality `QuickTime version <http://www-personal.umich.edu/~csev/courses/shared/podcasts/windows-python-notepad-plus.mov>`_
of the screen cast. You will need Apple QuickTime installed to view this video. )

Start NotePad++ from either a Desktop icon or from the Start Programs menu and enter your first Python program into NotePad++:

.. image:: Figures/helloworld.JPG
:width: 300px

Save your program as ``firstprog.py``. You can save it anywhere. In a little while we'll
create a code folder in a convenient place on your machine and you can resave the file then.
You will notice that after you save the file, NotePad++ will color your code based on the Python syntax rules.
Syntax coloring is a very helpful feature as it gives you visual feedback about your program and can help you track down syntax errors more easily.
NotePad++ only knows that your file is a Python file after you save it with a ``.py`` suffix, also known as file extension. It's like the ``.txt`` file extension we've seen that means a file is a plain text file, except this ``.py`` extension means that this file is a Python program.

.. image:: Figures/firstprog.JPG
:width: 300px


.. _mac_install:

Mac Instructions
================

The editor that we will help you to use is called **TextWrangler**. (TextWrangler and Notepad++ are very similar, but one runs on Macs and one runs on Windows.) Please download it from
`the TextWrangler site <http://www.barebones.com/products/TextWrangler/download.html>`_. Download it and then run the installer to install TextWrangler, like you would most programs you download.

TextWrangler may ask you to register for something, or to install other programs. You can hit Cancel -- you do not need to register for anything to use TextWrangler, you do not need any other programs, and it will not expire.

Follow the instructions that follow. It should be
quite intuitive. Keep in mind the concepts from earlier -- TextWrangler is an environment (a piece of software)
for _creating_ python programs. It's not intended (in this course) for running them!

Start TextWrangler from a Dock shortcut icon, finding it in your Applications folder, or startinit from Spotlight. Enter your first Python program into TextWrangler:

.. image:: Figures/helloworldmac.png
:width: 300px

Save your program as ``firstprog.py``, in your 106 folder. You will notice that after you save the file, TextWrangler will color your code based on the Python syntax rules. That's because you saved it with the ``.py`` file extension, which tells the computer this file is a Python program.

Syntax coloring is a very helpful feature, as it gives you visual feedback about your program and can help you track down syntax errors more easily.
TextWrangler only knows that your file is a Python file after you save it with a ``.py`` suffix, also known as file extension. It's like the ``.txt`` file extension we've seen that means a file is a plain text file, except this ``.py`` extension means that this file is a Python program.

.. image:: Figures/firstprogram_tw.png
:width: 300px

62 changes: 62 additions & 0 deletions pip2/source/Installation/pythonInstall.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. Copyright (C) Brad Miller, David Ranum, Jeffrey Elkner, Peter Wentworth, Allen B. Downey, Chris
Meyers, Dario Mitchell, Paul Resnick. Permission is granted to copy, distribute
and/or modify this document under the terms of the GNU Free Documentation
License, Version 1.3 or any later version published by the Free Software
Foundation; with Invariant Sections being Forward, Prefaces, and
Contributor List, no Front-Cover Texts, and no Back-Cover Texts. A copy of
the license is included in the section entitled "GNU Free Documentation
License".
Now, you'll need to install the Python interpreter on your computer. This process will again be a little bit different depending on whether you have a computer that runs a Mac or the Windows operating system. Follow the appropriate set of instructions:

.. _windows_python_install:

Install and configure python for Windows
========================================

Please download and install Python 2.7 from:

http://python.org/download/releases/2.7.6/

Download and install the file python-2.7.6.msi - when the install process asks you which directory to use - make sure to keep the default directory of C:\Python27\. If you are not sure if your Windows is 64-bit - install the 32-bit version of Python, the
one that just says, "Windows x86 MSI Installer (2.7.6) (sig)".

.. note::

Make sure that you install the latest version of Python 2.x - do not install Python 3.x.
There are signficant differences between Python 2 and Python 3 and this book/site is based on Python 2.

With just this installation, you can get an interactive python interpreter where
you can type code one line at a time and have it executed. You may find some options
on the Windows menu for this, such as Idle. We *do not* recommend using these.

With just this installation it is also possible to run python from the Windows command prompt.
But the Windows command prompt is tricky to deal with. To establish
greater consistency with the environment in which Mac users will be working and
because it's just a better command prompt, we will invoke Python using Git Bash.


.. _mac_python_install:

Install and configure python for Mac
====================================

Because you have a mac, you're lucky in this case (though you can develop fine on any operating system!) -- you already have Python. It comes pre-installed. However, we need to make sure you have the correct version of Python. We will be using version **2.7.**

If you have Mac OS 10.7 (Lion) or later, you definitely have Python 2.7. If you have Mac OS 10.6 (Snow Leopard) or earlier, you may have a different version of Python. If so, let's get this straightened out early -- come see one of the instructors. (If this applies to many people, we will provide additional instructions for that installation!)

To find out what version of Python you have, you'll first need to open your Terminal program.

Now you're going to use a command that will tell us what version of python you have installed on your mac.

Type: ``python -V``, and press return. That process should look something like this:

.. image:: Figures/typedpython.png
:width: 300px

.. image:: Figures/returntypedpython.png
:width: 300px

If you see a 2.7 (and the third number can be anything) on the screen, like in that image above, you're fine. If you get an error, please see one of the instructors!

You're now all ready to run Python.
24 changes: 24 additions & 0 deletions pip2/source/Installation/runpythonprograms.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. Copyright (C) Brad Miller, David Ranum, Jeffrey Elkner, Peter Wentworth, Allen B. Downey, Chris
Meyers, Dario Mitchell, Paul Resnick. Permission is granted to copy, distribute
and/or modify this document under the terms of the GNU Free Documentation
License, Version 1.3 or any later version published by the Free Software
Foundation; with Invariant Sections being Forward, Prefaces, and
Contributor List, no Front-Cover Texts, and no Back-Cover Texts. A copy of
the license is included in the section entitled "GNU Free Documentation
License".
.. _run_code_file:

Run a Python Code File
======================

Finally, you are ready to run a python program! At the terminal window, type ``python secondprog.py``. This will invoke the python interpreter, executing the code in file secondprog.py. That file just contains the line ``print "hello world"``, so *hello world* is output to the console. Notice that the console is just the area in the terminal window underneath where you entered the command that invoked python.

.. image:: Figures/secondprog1.JPG

.. note::

If in a terminal window you type ``python`` without specifying a filename, it launches the **python interpreter** and gives a little different command prompt. It's then waiting for you type python commands one at a time, which it immediately evaluates. In my experience, using the python interpreter is very confusing for beginning students, because it mixes up the idea of printed representations being generated only by explicit print statements (print is for people!). If you accidentally launch the python interpreter, I encourage you to just kill it, by typing ``exit()``.

.. image:: Figures/pythoninterpreter.JPG
5 changes: 4 additions & 1 deletion pip2/source/toc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,12 @@ Installation
:maxdepth: 2

Installation/FirstSteps.rst
Installation/NextSteps.rst
Installation/TextEditor.rst
Installation/pythonInstall.rst
Installation/runpythonprograms.rst



Unix
::::

Expand Down

0 comments on commit b298779

Please sign in to comment.