How to install and use Anaconda

We recommend using the Anaconda distribution to install Python, Spyder as your programming environment, and Jupyter Notebook for creating interactive documents.

Installing Anaconda

Mac

  1. Open https://www.anaconda.com/download in your web browser.
  2. Download the Anaconda installer (Python 3 version) for macOS.
  3. Install Anaconda using all of the defaults for installation.

Make sure to click Install for me only if the installer says: You cannot install Anaconda3 in this location. The Anaconda3 installer does not allow its software to be installed here.

Refer to the detailed step-by-step instructions for Mac if needed.

Windows

  1. Open https://www.anaconda.com/download in your web browser.
  2. Download the Anaconda installer (Python 3 version) for Windows.
  3. Install Anaconda using all of the defaults for installation.

Refer to the detailed step-by-step instructions for Windows if needed.

Linux

  1. Open https://www.anaconda.com/download in your web browser.
  2. Download the Anaconda installer (Python 3 version) for Linux, make a note of the filename.
  3. Open a Terminal window, and type bash followed by the name of the file you downloaded, for example:
    bash ~/Downloads/Anaconda3-5.0.0.1-Linux-x86_64.sh

Refer to the detailed step-by-step instructions for Linux if needed.

Anaconda may also be run from the calcfarm.ntnu.no server, but it is highly recommended to install it on your own computer. Learn how to connect to Calcfarm if you are unable to install Anaconda.

[jump to top of page]

Starting Spyder

The Spyder editor supports interactive testing, debugging, a variable explorer and other nice things.

To start Spyder, first open Anaconda Navigator:

  • Mac: You'll find Anaconda Navigator in Launchpad (and also in the Applications folder). Drag it to the Dock if you want to have it readily available.
  • Windows: You'll find Anaconda Navigator in the Start menu.
  • Linux: Open a terminal window and run the command anaconda-navigator.

Then, click the Launch button below the Spyder icon on the Navigator Home tab:

[jump to top of page]

Starting Jupyter Notebook

A Jupyter Notebook lets you combine code, explanatory text, mathematics, plots, and more in a single document.

Notebook documents contain the inputs and outputs of your computation, and can serve as a complete computational record of a session, making it easy to share reproducible work.

To start Jupyter Notebook, first open Anaconda Navigator as described in the previous section, then click the Launch button below the Jupyter Notebook icon.

To start using Notebooks, read more about:

Example notebooks

Download the notebook file to open the full, interactive notebook on your own computer, or view a static version of the notebook online:


[jump to top of page]

Working with course-specific environments

If your course needs other packages than those installed by default, these will be installed in a separate environment, and you'll need to use that environment for course work. The steps involved are:

  • Update your Anaconda installation
  • Import the .yaml file you got from your teacher
  • Start Spyder from the correct environment

Step 1 of 3: Update your Anaconda installation

First, open an Anaconda Prompt:

  • Windows:
    • Open Anaconda Prompt from the Start menu.
    • Close all other open Anaconda programs, including Anaconda Navigator and Spyder.
  • Mac:
    • Open Terminal from Launchpad, or from the Applications folder (look inside the Utilities folder).
  • Linux:
    • Open a terminal window.

Then, run the following two commands:

conda update -y conda

and:

conda update -y anaconda

Step 2 of 3: Import the .yaml file

Download the .yaml file from the course home page and save it to your computer.

Open Anaconda Navigator and click the Environments tab in the left menu. Then click Import and select the .yaml file you downloaded.

For more information, refer to Managing environments in the Anaconda documentation.

Step 3 of 3: Starting Spyder from the correct environment

To use this environment, you must select it from the drop-down menu in the Home tab before starting Spyder:

[jump to top of page]

Recommendations for teachers

If you are using Python in your course, we recommend that you:

Install Anaconda exactly as described above, and use this version to create exercises. There may be differences between the packages in your "normal" Python installation and those that Anaconda comes with, and you should run exactly the same environment as your students will.

If you need extra packages, do not ask your students to install them using conda or pip commands. Instead,

  1. Export the environment to a .yaml file, and publish this file on the course home page.
  2. Direct the students to the Working with course-specific environments section on this page.

[jump to top of page]

Debugging Python programs

A short introduction to debugging Python programs in Spyder are available in English and Norwegian:

[jump to top of page]

2018-06-25, Per Kristian Hove