NESW Workshop
Telling Science Stories with Code and Data
Software You’ll Need
If you want to follow along with the workshop curriculum, you will need a reasonably modern computer with an up-to-date web browser and about a gigabyte of available space on the disk drive for newly installed software. (All of the software can easily be removed later, if you need to recover the disk space.)
Installing Python
Even if you already have a version of Python on your machine, we suggest installing the Anaconda distribution from Continuum Analytics. It won’t interfere with your existing setup, and you can remove it later with no fuss.
- Go to http://continuum.io/downloads/. You should be offered an installer tailored to your operating system.
(If you’re offered the wrong choice, click one of the three icons at the top of the panel—windowpane, apple, tux.)
- Unless you’re a command-line guru, you probably want the “Graphical Installer.”
- Please choose Python version 2.7, which is the default option, not Python 3.4.
- Click the button to start the download. Now might be a good time to get a cup of coffee; it’s a big file.
- When the download completes, you should have a
.pkg
file on Macintosh or an.exe
file on Windows. In either case, double-click it. - The installer program has its own on-screen instructions, and there’s also a walk-through on the Anaconda website.
- You need to choose a place to put the software. On Macintosh the default choice is your home directory. The installer may display an error message: “You cannot install Anaconda in this location.” In fact you can, if you just click another choice and then return to the home-folder selection. Or you can put the software anywhere else you’d like, such as the main “Applications” folder. (You may be asked for an administrator password.)
- If all goes well, you’ll get a message saying the installation was successful.
- And what if all doesn’t go well? You might find a LiveChat icon on the Continuum.io install page. There’s a FAQ. There’s an Anaconda Issues page on GitHub. There’s a Google Group where you can ask for help.
- Once you’ve completed the installation, you can throw away the installer (the
.pkg
or.exe
file).
Trying Out Python and IPython Notebook
Let’s try out that shiny new programming language!
- On Macintosh, open the new “anaconda” folder. Among the files and folders inside, you’ll find one called “Launcher” or “Launcher.app”; double click it. On Windows, Launcher will be found in the Start menu.
- After a few seconds, a list of launchable programs should appear; find the one labeled “ipython-notebook.” Click the dark blue “Launch” button (not the “Update” button, if there is one).
- A Terminal window may appear briefly, then your web browser should launch; if the browser is already running, a new window or tab will open up. The banner at the top of the window will say “Jupyter.”
- In the Jupyter/IPython window you’ll see a list of files and folders, and near the upper right corner a “New” button. Clicking on “New” reveals a short menu; choose the “Python2” item.
- Yet another tab or window should now open in the browser. At last you have reached the promised land of the notebook! This is where you have a conversation with the Python interpreter. You write a Python expression in a box that has an
In [ ]:
prompt; the interpreter replies in anOut [ ]:
box. Of course it’s not so easy to write a Python expression if you don’t know any Python. Let us resort to mathematics, the universal language. Type in a simple addition or multiplication problem, then pressAlt-Enter
(orOpt-Enter
on Macintosh): - Feel free to explore further. You might start by visiting the Help menu and taking the user interface tour. Or type ‘?’ into a cell (and press
Alt/Opt-Enter
). For a deeper dive, go to the workshop Python page and download the IPython notebook you’ll find there.
Installing the Brackets Editor for JavaScript
For JavaScript programming, you don’t need to install JavaScript itself; the machinery for running JavaScript programs is already built into your web browser. What you do need is an editor program—a piece of software that will help you write JavaScript programs, and also the HTML and CSS files that form part of a web document. In principle, you could use any editor that produces plain text output, such as Notepad on Windows of Textedit on Macintosh. But a more specialized editor—one designed explicitly for writing code—will make your life easier with hundreds of little amenities such as indenting lines automatically, balancing quotation marks and parentheses, and suggesting likely continuations as you type.
We recommend an editor called Brackets. Development of the software was initiated by Adobe Systems, but Brackets is now an open-source software project with a large community of contributing programmers. (The source code is on GitHub.) Brackets is still new and evolving, but it already offers a pleasant environment for creating web documents and JavaScript programs. Especially nice is the ability to see the effects of your changes instantly in a browser window, without any need to set up a web server.
- Brackets works best with the Google Chrome web browser. If you don’t have Chrome installed, you can get a copy at www.google.com/chrome/. But if you’d rather stick with another browser, it will probably work.
- Download the Brackets installer from brackets.io. (The big blue download button will also fetch an Adobe program called Extract, but there’s a link in small type just below the button that gets you Brackets alone.) On Macintosh you’ll get a
.dmg
file; double click it to open the disk archive, then drag the application icon to some appropriate spot on your disk, such as an Applications folder. The Windows download is an.msi
file, which you can double click to install. - Now doubleclick the application icon to start the Brackets program itself. You’ll see a window displaying the text of a file named
index.html
. Near the top of the right margin of this window is a gray lightning bolt,, which should turn orange when you click it:
. The spark represents a link to a live preview, which opens in a new window or tab in the Chrome browser, showing the fully formatted web page.
- If Chrome is not installed, you’ll get an error message complaining that it can’t be found. If you choose not to install Chrome, go to the Brackets
File
menu and click the itemEnable Experimental Live Preview
. That should allow the preview to appear in your default browser. - Other problems? Try the troubleshooting file.
Next steps. The “Getting Started with Brackets” file that opens automatically when the program is first run has some basic information; there’s more in the Brackets Wiki, including videos and a troubleshooting guide.
If you’re unhappy with the aesthetics of the editor, you can install a new theme. Go to the file menu and click on Extension Manager...
for a list of options. There are also some dozens of extensions that do useful or silly things.
When you’re ready to start exploring JavaScript programming, take a look at JavaScript in a Jiffy.