-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
557 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,36 @@ | |||
<?php include("top.php");?> | |||
<?php include("nav.php");?> | |||
<div class="hide-for-large" id="mobile-support"></div> | |||
<div id="first-row" class="row"> | |||
<div class="small-12 columns"> | |||
<h2>Setting up your PythonLearn Devlopment Environment</h2> | |||
<p> | |||
We have separate pages for each of the commonly used Operating Systems: | |||
</p> | |||
<ul> | |||
<li> | |||
<a href="software-win.php">Setting up the PythonLearn Environment in Microsoft Windows</a> | |||
</li> | |||
<li> | |||
<a href="software-mac.php">Setting up the PythonLearn Environment on a Macintosh</a> | |||
</li> | |||
<li> | |||
<a href="software-pi.php">Setting up the PythonLearn Environment on a Raspberry Pi</a> (New) | |||
</li> | |||
<li> | |||
Can't or don't want to install software on your computer? Check out <a href="http://trinket.io">Trinket</a>, | |||
<a href="https://www.pythonanywhere.com/">PythonAnywhere</a>, <a href="http://c9.io">Cloud9</a>, or | |||
<a href="http://codeanywhere.com">CodeAnywhere</a>. | |||
</li> | |||
</ul> | |||
<p> | |||
<b>Note:</b> Make sure that you have Python 2.6.1 or later but do not install Python 3.x. There are signficant differences between Python 2 and Python 3 and this book and class is still Python 2. | |||
</p> | |||
<p> | |||
You will need <a href="http://www.apple.com/quicktime" target=_new>Quicktime</a> (or iTunes) installed on your computer to view any video materials or screencasts. You should probably download the high quality copies of these files or screencasts to your computer and view/play them locally. They are rather large files and you will want to move back and forth as well as start and stop the podcasts so you can perform the steps as indicated. | |||
</p> | |||
|
|||
</div> | |||
</div> | |||
<?php include("footer.php"); ?> | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,151 @@ | |||
<?php include("top.php"); ?> | |||
<?php include("nav.php"); ?> | |||
<div class="hide-for-large" id="mobile-support"></div> | |||
<div id="first-row" class="row"> | |||
<div class="small-12 columns"> | |||
<h3> | |||
Setting up the PythonLearn Environment on a Macintosh | |||
</h3> | |||
<p>Python is already installed on Macintosh OS/X operating system so all you need to add | |||
is a programmer text editor. | |||
</p> | |||
<h3>Pre-Requisite: TextWrangler</h3> | |||
<p>Please download and install TextWrangler from this site. | |||
</p> | |||
<p><a href="http://www.barebones.com/products/TextWrangler/download.html" target="_new">http://www.barebones.com/products/TextWrangler/download.html</a> | |||
|
|||
<p> | |||
<b>Important:</b> Before you create your first program, you need to make one small change in the | |||
Preferences for TextWrangler. This will save you lots of "Python indent errors" anguish later. | |||
Under <b> TextWrangler -> Preferences -> Editor Defaults</b> tick the check box | |||
for "Expand Tabs" and close the dialog box | |||
(<a href="textwrangler_tabs_prefs.png" target="_new">Screenshot</a>). | |||
|
|||
<h3>Editing With TextWrangler</h3> | |||
<p> | |||
<b>Note:</b> We have a screen cast for the use of TextWrangler. You can either view this on | |||
<!-- Note to self - Vimeo cannot handle these files - so YouTube is what we get --> | |||
<a href="http://www.youtube.com/watch?v=et2vjUAz9-k" target="_new">YouTube</a> or you can | |||
download the high-quality | |||
<a href="http://www-personal.umich.edu/~csev/courses/shared/podcasts/mac-python-textwrangler.mov" | |||
target="_new">QuickTime version</a> of the screen cast. | |||
You will need Apple QuickTime installed to view this video. | |||
</p> | |||
<p> | |||
Go into the upper-right of your screen and click on the Spotlight search button and type <b>textwrangler</b>. | |||
|
|||
<p> | |||
Then create your first Python program. | |||
<pre> | |||
print "Hello World" | |||
</pre> | |||
<p>Save your program as firstprog.py onto your Desktop. | |||
You will notice that after you save the file, TextWrangler 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. TextWrangler only knows that your file is a Python file after you save it with a ".py" suffix. | |||
</p> | |||
|
|||
<h3>Running Python Using the Built-In TextWrangler Shortcut</h3> | |||
<p> | |||
TextWrangler has a built-in way to run a Python program directly from | |||
the TextWrangler user interface. In TextWrangler go to the menu item <b>#! -> Run in Terminal </b> | |||
<p> | |||
TextWrangler will bring up a terminal window and automatically execute Python on your program. | |||
You will have to look closely to pick out the output from your program amongst the rest of the output in the terminal window. | |||
<p> | |||
In general, you can use the TextWrangler shortcut for very simple programs but once you start | |||
reading and writing files in your Python programs you should open and use the terminal program | |||
so you know what directory your program is running in - so you can open and read files. | |||
|
|||
<h3>Starting Terminal on Macintosh OS/X</h3> | |||
<p> | |||
The Terminal program on Macintosh is kind of buried under <b>Macintosh HD -> Applications -> Utilities -> Terminal</b> | |||
<p> | |||
There are several shortcuts that you might find helpful. You can go into the upper-right of | |||
your screen and click on the Spotlight search button and type | |||
<b>terminal</b> and you can execute Terminal from the pop-up | |||
list of items. | |||
<p> | |||
You can get Terminal to stay in your dock once terminal is launched by clicking and | |||
holding on the Terminal icon in the dock and then selecting Keep in Dock. | |||
Then you can quickly launch Terminal by clicking on the icon in the dock. | |||
|
|||
<h3>Where Are You?</h3> | |||
<p> | |||
When the command line starts up, you are in your "home" directory. | |||
In each of these examples, your logged in account should be used instead of csev. | |||
<pre> | |||
Macintosh Home Directory: /Users/csev | |||
</pre> | |||
The command line prompt usually includes some clue as to where you are at | |||
in the folder structure on your hard drive. If you want to really figure out | |||
where you are, on Macintosh use the <b>pwd</b> command. | |||
<pre> | |||
udhcp-macvpn-624:~ csev$ pwd | |||
/Users/csev | |||
udhcp-macvpn-624:~ csev$ | |||
</pre> | |||
|
|||
<h3>Where can you go?</h3> | |||
<p> | |||
Generally the first thing you want to do when you open a command line | |||
interface is to navigate to the right folder. Say you wanted to run a file from your desktop. The command is | |||
<b>cd Desktop </b> | |||
<pre> | |||
udhcp-macvpn-624:~ csev$ pwd | |||
/Users/csev | |||
udhcp-macvpn-624:~ csev$ cd Desktop | |||
udhcp-macvpn-624:Desktop csev$ pwd | |||
/Users/csev/Desktop | |||
udhcp-macvpn-624:Desktop csev$ | |||
</pre> | |||
Nifty Trick: On the cd command, you can partially type a folder name like Desktop | |||
and then press the TAB key and the system will auto-complete the folder name | |||
if you have typed enough that the system can accurately guess what you mean to type. | |||
<p> | |||
Going Backwards (or Upwards) | |||
<p> | |||
You can change directory to the parent folder (the folder "above" the folder you | |||
are in using the <b>cd ..</b> command. It just says "go up one". | |||
<pre> | |||
udhcp-macvpn-624:Desktop csev$ pwd | |||
/Users/csev/Desktop | |||
udhcp-macvpn-624:Desktop csev$ cd .. | |||
udhcp-macvpn-624:~ csev$ pwd | |||
/Users/csev | |||
udhcp-macvpn-624:~ csev$ | |||
</pre> | |||
If you get Lost... | |||
<p> | |||
If you can't figure out what folder you are in and/or cannot figure | |||
out how to get to the folder you want to get to "home" simply close and | |||
re-open the Command Line / Terminal window. | |||
<p> | |||
What Files/Folders are Here? | |||
<p> | |||
You can list the contents of the current directory using the <b>ls -l</b> command. | |||
<pre> | |||
udhcp-macvpn-624:Desktop csev$ pwd | |||
/Users/csev/Desktop | |||
udhcp-macvpn-624:Desktop csev$ ls -l | |||
total 8 | |||
-rw-r--r-- 1 csev staff 15 Sep 16 15:17 firstprog.py | |||
udhcp-macvpn-624:Desktop csev$ | |||
</pre> | |||
Running Your Python Program in the Terminal | |||
<p> | |||
Start the Terminal program, navigate to the proper directory and type the following command: | |||
<pre> | |||
python firstprog.py | |||
</pre> | |||
This loads the Python interpreter and runs <b>firstprog.py</b>, showing the program output and/or errors | |||
in the Terminal window. | |||
<p> | |||
Some Cool Hints on The Macintosh Terminal Program | |||
<p> | |||
You can scroll back through previous commands by pressing the up and down arrows and re-execute | |||
commands using the enter key. This can save a lot of typing. | |||
If you like keeping your screen uncluttered, you can clear the scroll | |||
back buffer by pressing the Command key and the K key at the same time. | |||
</div> | |||
</div> | |||
<?php include('footer.php');?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,135 @@ | |||
<?php include("top.php"); ?> | |||
<?php include("nav.php"); ?> | |||
<div class="hide-for-large" id="mobile-support"></div> | |||
<div id="first-row" class="row"> | |||
<div class="small-12 columns"> | |||
<h3> | |||
Editing and Running Python Programs on the Rasberry Pi | |||
</h3> | |||
<p> | |||
The <a href="http://www.raspberrypi.org" target="_new">Raspberry Pi</a> is a low-cost ($5 to $35US) complete Linux computer. It is a great platform for writing | |||
Python programs and learning about computers in general. | |||
</p> | |||
<p> | |||
We won't cover getting a RasPi up and running here - but the nice thing is that | |||
once it is up and running there is nothing else needed to develop the | |||
programs for this class. | |||
</p> | |||
<h3>Writing "Hello World" on the Raspberry Pi</h3> | |||
<p> | |||
You can either view screen cast for these instructions on | |||
<a href="http://www.youtube.com/watch?v=wfX8NRCeX3A" target="_new">YouTube</a> or you can | |||
download the high-quality | |||
<a href="http://www-personal.umich.edu/~csev/courses/shared/podcasts/raspi-hello-world.mp4" | |||
target="_new">MP4 version</a> of the screen cast. | |||
You will need Apple QuickTime or some other MP4 viewer | |||
installed to view this video. The quality is much higher and the | |||
details are easier to read on the MP4 version. | |||
</p> | |||
<p> | |||
Go to the lower-right of your screen and click on the Start icon and then | |||
go to <b> Accessories -> Leafpad</b>. Leafpad is the text editor. | |||
</p> | |||
<p> | |||
Then create your first Python program. | |||
<pre> | |||
print "Hello World" | |||
</pre> | |||
<p>Save your program as firstprog.py onto your Desktop. | |||
|
|||
<h3>Starting Terminal </h3> | |||
<p> | |||
While there are many ways to run a Python program under Linux, we will prefer | |||
using the terminal program. | |||
There are several terminal programs on the Raspian Linux - my favourite is at | |||
</p> | |||
<b>Start -> Accessories -> LXTerminal</b> | |||
</p> | |||
LXTerminal has a nice preferences feature to allow you to change the | |||
size and color of the text. | |||
<h3>Where Are You?</h3> | |||
<p> | |||
When LXTerminal starts up, you are in your "home" directory. | |||
In each of these examples, your logged in account should be used | |||
instead of csev. | |||
<pre> | |||
Home Directory: /home/csev | |||
</pre> | |||
The command line prompt usually includes some clue as to where you are at | |||
in the folder structure on your hard drive. If you want to really figure out | |||
where you are, on Linux use the <b>pwd</b> command. | |||
<pre> | |||
csev@rasberrypi:~$ pwd | |||
/home/csev | |||
csev@rasberrypi:~$ | |||
</pre> | |||
|
|||
<h3>Where can you go?</h3> | |||
<p> | |||
Generally the first thing you want to do when you open a terminal program | |||
is to navigate to the correct folder. | |||
Say you wanted to run a file from your Desktop. The command is | |||
<b>cd Desktop </b> | |||
<pre> | |||
csev@rasberrypi:~$ pwd | |||
/home/csev | |||
csev@rasberrypi:~$ cd Desktop | |||
csev@rasberrypi:~$ pwd | |||
/home/csev/Desktop | |||
csev@rasberrypi:~$ | |||
</pre> | |||
Nifty Trick: On the cd command, you can partially type a folder | |||
name like Desktop | |||
and then press the TAB key and the system will auto-complete | |||
the folder name if you have typed enough that the system can | |||
accurately guess what you mean to type. | |||
<p> | |||
Going Backwards (or Upwards) | |||
<p> | |||
You can change directory to the parent folder | |||
(the folder "above" the folder you | |||
are in using the <b>cd ..</b> command. It just says "go up one". | |||
<pre> | |||
csev@rasberrypi:~$ pwd | |||
/home/csev/Desktop | |||
csev@rasberrypi:~$ cd .. | |||
csev@rasberrypi:~$ pwd | |||
/home/csev | |||
csev@rasberrypi:~$ | |||
</pre> | |||
If you get Lost... | |||
<p> | |||
If you can't figure out what folder you are in and/or cannot figure | |||
out how to get to the folder you want to get to "home" simply close and | |||
re-open the Command Line / Terminal window. | |||
<p> | |||
What Files/Folders are Here? | |||
<p> | |||
You can list the contents of the current directory using the <b>ls -l</b> command. | |||
<pre> | |||
csev@rasberrypi:~$ pwd | |||
/home/csev/Desktop | |||
csev@rasberrypi:~$ ls -l | |||
total 4 | |||
-rw-r--r-- 1 csev csev 15 Jan 9 15:17 firstprog.py | |||
csev@rasberrypi:~$ | |||
</pre> | |||
<h3>Running Your Python Program in the Terminal</h3> | |||
<p> | |||
Start the Terminal program, navigate to the proper directory and | |||
type the following command: | |||
<pre> | |||
csev@rasberrypi:~$ python firstprog.py | |||
</pre> | |||
This loads the Python interpreter and runs | |||
<b>firstprog.py</b>, showing the program output and/or errors | |||
in the Terminal window. | |||
<p> | |||
<h3>Some Cool Hints on The Terminal Program</h3> | |||
<p> | |||
You can scroll back through previous commands by pressing the | |||
up and down arrows and re-execute | |||
commands using the enter key. This can save a lot of typing. | |||
</div> | |||
</div> | |||
<?php include('footer.php');?> |
Oops, something went wrong.