
Swampy: Installation Instructions
If you have Python and Tkinter, you
can install
Swampy from the Python Package Index.
If you need help installing Swampy, Tkinter or Python, see the
detailed instructions below. These instructions are a work in
progress; if you have suggestions for
improvement, let
me know.
Once you have Swampy installed, try out some of the examples is
this tutorial.
Python 3
Swampy for Python 3 is not available as a package. But the source
code is available in a zip file:
Swampy source for Python 3:
swampy-2.1.python3.zip
If you unzip this directory and add it to the Python search path, you
will be able to import Swampy modules, but instead of specifying the
package and module like this:
import swampy.TurtleWorld
You would just specify the module, like this:
import TurtleWorld
Swampy for Python 3 is relatively new, so please let me know if
you run into problems.
Linux
- Install Python
To see if you already have Python, open a terminal
(Applications->Accessories->Terminal) and type python on the
Linux command line.
You should see something like this:
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
>>>
If so, you have Python. If the version number starts with
2, you have Python 2, which is the version of Python
used in Think Python. If the version number starts with 3,
you have Python 3. You will not be able to use Swampy with Python 3.
To install Python on Ubuntu, run
sudo apt-get install python python-tk
Or for Python 3
sudo apt-get install python python3-tk
Or use the Synaptic Package Manager to install "python" and "python-tk".
For other distributions, you can find instructions at
python.org. You should
install the latest version of Python 2 (but anything after 2.4 should
work).
- Install Tkinter
To see if you have Tkinter, type python on the Linux command line.
Then at the Python prompt, type
>>> import Tkinter
Or in Python 3
>>> import tkinter
If you have Tkinter, Python will not print an
error message and you can go on to the next section.
Otherwise you will see something like this:
ImportError: No module named Tkinter
In that case, you have to install Tkinter. On Ubuntu, you can run
sudo apt-get install python-tk
Or for Python 3
sudo apt-get install python python3-tk
Or use the Synaptic Package Manager to install "python-tk".
For other distributions, you can get more information from the
Tkinter wiki.
- Install Swampy
To see if you have Swampy, type python on the Linux command line.
Then at the Python prompt, type
>>> import swampy.TurtleWorld
If you have Swampy, Python will not print an
error message and you are all set. Enjoy the book!
Otherwise you will see something like this:
ImportError: No module named swampy.TurtleWorld
In that case, you have to install it.
Swampy is available from PyPI,
the Python Package
Index.
If you use easy_install, you can install it like this:
sudo easy_install swampy
If you use pip, you can install it like this:
sudo pip install swampy
Otherwise, instructions for installing packages from PyPI
are here.
If you follow their instructions for Distutils, you might need to know
how to "extract the distribution." Download the gzipped tar file
(with the suffix .tar.gz). Make sure you are in the
directory where you downloaded the file and type
tar -xzf swampy-*.tar.gz
Then cd into the directory it creates:
cd swampy-x.x.x
You have to replace the x's with the version number, or use tab-completion
to avoid typing it.
Finally, run the installer according to the instructions
in the tutorial.
Macintosh
- Install Python
According to python.org,
Python comes pre-installed on Mac OS X, but due to Apple's release
cycle, it's often one or even two years old. The overwhelming
recommendation of the "MacPython" community is to upgrade your Python
by downloading and installing a newer version from the Python standard
release page.
Follow these
instuctions to install a current version of Python. You should
install the latest version of Python 2 (but anything after 2.4 should
work).
- Install Tkinter
To see if you have Tkinter, launch python;
then at the Python prompt, type
>>> import Tkinter
Or in Python 3
>>> import tkinter
If you have Tkinter, Python will not print an
error message and you can go on to the next section.
Otherwise you will see something like this:
ImportError: No module named Tkinter
In that case, you have to install Tkinter. You can
follow these
instructions from python.org.
- Install Swampy
To see if you have Swampy, launch python; then
at the Python prompt, type
>>> import swampy.TurtleWorld
If you have Swampy, Python will not print an
error message and you are all set. Enjoy the book!
Otherwise you will see something like this:
ImportError: No module named swampy.TurtleWorld
In that case, you have to install it.
Swampy is available from PyPI,
the Python Package
Index.
Instructions for installing packages from PyPI
are here.
If you follow their instructions for Distutils, you might need to know
how to "extract the distribution." Download the gzipped tar file
(with the suffix .tar.gz). Make sure you are in the
directory where you downloaded the file and type
tar -xzf swampy-*.tar.gz
Then cd into the directory it creates:
cd swampy-x.x.x
You have to replace the x's with the version number, or use tab-completion
to avoid typing it.
Finally, run the installer according to the instructions
in the tutorial.
Windows
Thanks to Jaymie for help improving these instructions. If you
have suggestions for additional improvements, please let me know.
- Install Python
For instructions on running Python under Windows, see
the Python Windows FAQ.
To run Python from the Command Prompt, you need to add the folder that
contains Python to the list of folders Windows searches for commands.
The name of the folder is probably C:\Python26
or C:\Python27.
To add this folder to the search path, select Control panel -> system
-> advanced -> Environmental Variables -> system variables -> Path.
Add C:\Python26 or C:\Python27 to the end of the
list (with a semi-colon as a separator).
Now if you restart the command window, you should be able to type
python at the prompt and launch Python.
- Install Tkinter
To see if you have Tkinter, launch python;
then at the Python prompt, type
>>> import Tkinter
Or in Python 3
>>> import tkinter
If you have Tkinter, Python will not print an
error message and you can go on to the next section.
Otherwise you will see something like this:
ImportError: No module named Tkinter
In that case, you have to install Tkinter.
You can download the
ActiveTcl
Community Edition from ActiveState, which should provide Tkinter.
If that doesn't work, there is more general information about Tkinter
here.
- Install Swampy
To see if you have Swampy, launch python; then
at the Python prompt, type
>>> import swampy.TurtleWorld
If you have Swampy, Python will not print an
error message and you are all set. Enjoy the book!
Otherwise you will see something like this:
ImportError: No module named swampy.TurtleWorld
In that case, you have to install it.
Swampy is available from PyPI,
the Python Package
Index.
Right click the file at the bottom of the page and save the file in
the site-packages folder (ex: C:\Python23\Lib\site-packages).
Next, right click the .tar.gz file in the folder and click "Extract
Here" to extract the file in the folder. The file should create a
"swampy-2.1.1" folder with all Swampy files.
Again, launch Python and see if you can
import swampy.TurtleWorld. If so, you are all set.
Otherwise, you might have to edit the PYTHONPATH folder to change the
environment and create a path to the file. Follow the instructions
here,
replacing the (c:\folder) with the location of the Swampy folder on
your computer (most likely
C:\Python27\Lib\site-packages\swampy-2.1.1).
Additional instructions for installing packages from PyPI
are here.
Back to the Swampy Home Page

|
Are you using Swampy in a class? We'd like to know
about it. Please consider filling out this short survey.
|