{ "metadata": { "name": "programming_environment_extras" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Programming Environment Extras\n", "===\n", "We use Ubuntu Linux as our main programming environment, for a number of reasons. This page covers a number of things we need to be aware of to help use and maintain a Linux computer." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Home](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/index.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Contents\n", "===\n", "- [Ubuntu Shortcuts](#ubuntu_shortcuts)\n", "- [Updating Ubuntu](#updating)\n", "- [Basic Terminal Commands](#basic_terminal_commands)\n", "- [Terminal Shortcuts](#terminal_shortcuts)\n", "- [Installing Python 3.3 on Ubuntu 12.04](#python3.3_ubuntu12.04)\n", "- [Installing Geany](#install_geany)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ubuntu Shortcuts\n", "===\n", "Knowing some simple shortcuts will help you do your programming work in linux.\n", "\n", "Switch windows\n", "\n", " Alt-tab" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[top](#)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Updating Ubuntu\n", "===\n", "Running updates is a good idea; it keeps your computer functioning appropriately." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "From the terminal\n", "---\n", "By taking this class, you have some interest in working with computers in a powerful way. The terminal is the most powerful way to use a linux computer, so let's jump in and use it whenever possible.\n", "\n", "Open a terminal using the keyboard shortcut Ctrl-Alt-T.\n", "\n", "Type the following command, and press enter:\n", "\n", " sudo apt-get update\n", "\n", "You will have to enter your password. Do this, and watch the information scroll by. Your computer is looking to find out which packages can be updated.\n", "\n", "Type the following command, and press enter:\n", "\n", " sudo apt-get dist-upgrade\n", "\n", "When you run this command, your computer downloads and installs all of the updates that were identified by the previous command." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[top](#)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Basic Terminal Commands\n", "===\n", "\n", "Packages\n", "---\n", "Install a package:\n", "\n", " sudo apt-get install package_name\n", "\n", "Uninstall a package, but keep its configuration files (dependencies?):\n", "\n", " sudo apt-get remove package_name\n", "\n", "Remove a package, and its configuration files (dependencies?):\n", "\n", " sudo apt-get remove --purge package_name\n", "\n", "Python\n", "---\n", "Start a Python interpreter, using the default version of Python on your system:\n", "\n", " python\n", "\n", "Start a Python interpreter, using a specific version of Python:\n", "\n", " python3.3\n", "\n", "Exit out of the Python interpreter:\n", "\n", " Ctrl-D" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[top](#)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Terminal Shortcuts\n", "===\n", "There are a few things that will help you become comfortable using the terminal.\n", "\n", "Open a terminal:\n", "\n", " Ctrl-Alt-T\n", "\n", "Scroll through your previous terminal commands:\n", "\n", " up arrow, down arrow\n", "\n", "Clear output from your terminal screen. You will still be able to scroll up and see previous output.\n", "\n", " Ctrl-L\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[top](#)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Installing Python 3.3 on Ubuntu 12.04\n", "===\n", "Ubuntu is still using Python 2.7 by default. It is fairly easy to install Python 3.3, however, and then be able to choose the version of Python you want to use.\n", "\n", "Add the \"deadsnakes\" package archive (ppa) to your system. This archive has a number of older and newer versions of Python. Then install python3.3.\n", "\n", " sudo apt-get install python-software-properties\n", " sudo add-apt-repository ppa:fkrull/deadsnakes\n", " sudo apt-get update\n", " sudo apt-get install python3.3\n", "\n", "Now that Python 3.3 is installed on your system, you have two options. You can start a default Python 2.7 session by running the command 'python' in a terminal. You can start a Python 3.3 session by running the command 'python3.3' in a terminal." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[top](#)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Installing Geany\n", "===\n", "Geany is one of the text editors we will use for writing programs. Geany is a simple editor, which makes it easy to run programs. Output is shown in a separate terminal window, which gets you used to working in terminals as well." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Open a terminal.\n", "\n", " sudo apt-get install geany\n", "\n", "Press the windows button, and type 'geany'.\n", "\n", "Drag the geany icon to the task bar on the left side of the screen. This creates a shortcut you can use to start geany.\n", "\n", "Write a Hello World program, and save it as 'hello.py'.\n", "\n", "There are three ways you can run a program in Geany:\n", "\n", "- Build > Execute\n", "- Press F5\n", "- Click the icon with three gears on it\n", "\n", "You should see a terminal window pop up, with your output in it." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Configuring Geany to use Python3.3\n", "---\n", "Open Geany, and open a Python [*Hello World*](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/hello_world.ipynb) program. If you don't have one on your system, write one and save it as *hello.py*, and run the program. This makes sure that Geany is trying to run Python programs. When you have a running *hello.py* program, go to Build >> Set Build Commands.\n", "\n", "Under 'Python commands', look for the 'Compile' line. Enter the following in the 'Command' box. Make sure you get the spaces right. You should have 'python3.3' followed by a space, and the rest of the command. If you have 'python 3.3', with a space between *python* and *3.3*, Geany will not be able to run your code.\n", "\n", " python3.3 -m py_compile \"%f\"\n", "\n", "Under 'Execute commands', look for the 'Execute' line. Enter the following in the 'Command' box, paying attention once again to the spaces.\n", "\n", " python3.3 \"%f\"\n", "\n", "Test your setup with a hello.py file, using Python 3.3 syntax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[top](#)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- - -\n", "[Home](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/index.ipynb)" ] } ], "metadata": {} } ] }