Very simple Python: Difference between revisions
Line 27: | Line 27: | ||
If you installed from the python.org, then they have some additional pages to offer help. | If you installed from the python.org, then they have some additional pages to offer help. | ||
On Windows, its not necessarily as straightforward as Linux, but it can be. It will help to read this [http://docs.python.org/2/faq/windows.html "frequently asked question" (FAQ) page] about Python on Windows to help you at first. | On Windows, its not necessarily as straightforward as Linux, but it can be. It will help to read this [http://docs.python.org/2/faq/windows.html "frequently asked question" (FAQ) page] about Python on Windows to help you at first. | ||
On a Macintosh OS X system using Python is very similar to other Unix platforms like Linux or BSD. There are some helpful notes at the [http://docs.python.org/2/using/mac.html Using Python on a Macintosh] website. | On a Macintosh OS X system using Python is very similar to other Unix platforms like Linux or BSD. There are some helpful notes at the [http://docs.python.org/2/using/mac.html Using Python on a Macintosh] website. | ||
Revision as of 05:13, 7 February 2013
Installing Python on your computer
Python is open source software availble for free from www.python.org. Version 2.7 is the current mature version that is widely supportly by other add-on modules, and is the one for which examples here are written. Python 3 is still under development and it currently lacks packages that are necessary for astronomy.
If you have Linux, then mostly likely you already have Python and you can stop here.
For other operating systems, consider using the academic version from Enthought Solutions if you meet their licensing terms for the free version. This version supplies Matplotlib, Numpy and Scipy which we will use. For more information about other options, see Python4Astronomers
Alternatively, the source of Python development has versions for MacOS and Windows of the base system that avoids the commercial (though free) route of other vendors:
Additional modules would have to be installed separately later.
Using Python in real time
The first step is to figure out how to start up Python on your computer after it is installed. In Linux you open a console and type "python" on the command line. You'll immediately see a prompt that looks like ">>" after which you can type Python code and see the results.
If you installed the Enthought distribution of Python on Windows or Mac, take a look at their release notes and website for additional advice on getting started.
If you installed from the python.org, then they have some additional pages to offer help. On Windows, its not necessarily as straightforward as Linux, but it can be. It will help to read this "frequently asked question" (FAQ) page about Python on Windows to help you at first. On a Macintosh OS X system using Python is very similar to other Unix platforms like Linux or BSD. There are some helpful notes at the Using Python on a Macintosh website.
Once you have a command line prompt you have access to all of Python's capabilities. We'll show you some simple examples here to test your installation and give you a quick sense of how to use it.
To exit Python in the interactive mode, use "Ctrl+d" or "exit()"