Wikier

Installing Python

Python is a programming language used in a few courses here at NTNU. In this article we will show you how to install Python on different operating systems.

Norsk versjon Installere Python

Looking for something else? Topic page about Software | Pages marked development

Use at NTNU

Python is part of the curriculum in TDT4110 (Information Technology, Introduction) and is the preferred language in TDT4120 (Algorithms and Data Structures). We would advise you to ask your professor which version of Python they will be using. 

Available to

Python is a free software available to everyone, and you can find the installation package from their own website.

Installation

Windows

Install the latest version of Python

Here is a quick guide on how to install the latest version of Python on Windows

  1. Go to python.org and press the yellow Download Python-button.
  2. Open the .exe file when it is downloaded.
    • If this is the only version of Python you want to install, tick the Add Python 3.7 to PATH-checkbox in the setup-window. This will make it easier to run Python through the Command Prompt or Powershell.
    • If you have multiple versions of Python installed leave it unchecked. 
    Click Install Now.
  3. Optional 
    Click Disable path length limit, this wil allow you to bypass the built-in path limit of 260 characters and save you a lot of potential headache. If you intend to save your Python code deep within the darkest depths of a million folders, you might end up with a path that exceeds 260 characters. This will make it impossible to compile the code, unless you disable the path length limit.
  4. Click Close.

Together with Python you get a simple IDE (Integrated Development Environment) called IDLE if you start this program you can write and run Python-code. Learn more about IDLE from the Python Software Foundation.

Install an older version of Python

To install an older version of Python you will have to pick the correct installation-package. Which package you should choose depends on your version of Windows, if it's 32- or 64-bit.

  1. Open the System-page by pressing the Windows-key + Pause/Break or by opening: 
    Control Panel -> System and Security -> System
    Under System type you can see if your operating system is 64-bit or 32-bit.
  2. Go to Python.org and scroll through the list to find the Python release version that you want. Click on the name of the Python version, this will open a new page.
  3. Scroll to the bottom of the new page, under "Files" you will see that there are several installers available for download. Below you can see which one you should download depending on the Python version you selected and if you have a 32- or 64-bit system. 
    • For 32-bit Windows: Choose Windows x86 executable installer or Windows x86 MSI Installer
    • For 64-bit Windows: Choose Windows x86-64 executable installer or Windows x86-64 MSI Installer.
  4. Open the .exe/.msi file when it is downloaded, this will start the installer.
  5. Only applies to some versions 
    You might get the option to Add Python to PATH. Doing this will make it easier to run Python through the Command Prompt or Powershell. If you have multiple versions of Python installed it is best to leave this option unchecked.
  6. Optional and only applies to some versions
    You might get the option to Disable path length limit, this will allow you to bypass the built-in path limit of 260 characters and save you a lot of potential headache. If you intend to save your Python code deep within the darkest depths of a million folders, you might end up with a path that exceeds 260 characters. This will make it impossible to compile the code, unless you disable the path length limit.
  7. Click your way through the installer with the standard settings.

Together with Python you get a simple IDE (Integrated Development Environment) called IDLE if you start this program you can write and run Python-code. Learn more about IDLE from the Python Software Foundation.

Mac OS X

An old version of Python is often pre-installed on OS X, You should never modify or delete this version of Python, as it is Apple-controlled and is used by Apple- and third-party software.

Install the latest version of Python

We recommend installing a new version of Python side by side with the built-in version. Installing the latest version of Python is very simple:  

  1. Go to Python.org and press the yellow download-button. 
  2. Open the file when it is downloaded and click your way through the installer using the standard installation settings. Note that the new version of Python will be installed next to the built-in one, so be aware of which version you are actually using.
  3. Test that everything is working by running the new version of Python through the terminal. Open Terminal, type in "python3" and press Enter. Now you should be able to write Python-code directly into the terminal, try for example writing "15+54" or "print("hello world")"

Together with Python you get a simple IDE (Integrated Development Environment) called IDLE if you start this program you can write and run Python-code. Learn more about IDLE from Python Software Foundation

Install an older version

Installing an older version of Python takes a bit more work, but some courses require you to use an older version of Python. You should check with your professor to find out which version you should install.

Here are the steps you need to go through to install an older version:

  1. Find your version of OS X by clicking the Apple icon() in the top left corner of your screen, and clicking About this Mac. The version number should be below the Apple logo/MacOS-name in the new window.
  2. Go to Python.org, scroll through the release version list and click on the Python version that you want. 
  3. Scroll to the bottom of the new page and download the installer to fit you OS X version number
  4. When the .dmg/.pkg file is downloaded, double click the installer package. The installation itself is pretty straight forward, and you can use the standard options and click your way through.
    Note that the "new" version of Python will be installed next to the built-in one, so be aware of which version you are actually using.

Together with Python you get a simple IDE (Integrated Development Environment) called IDLE if you start this program you can write and run Python-code. Learn more about IDLE from Python Software Foundation

Linux

Python should be preinstalled on Linux, but it could be an outdated version. Updating is typically not necessary to get through any of the courses, but it can sometimes fix a few bugs. Again, you should check with your professor to make sure.

To update Python, go to the terminal window and write:

sudo apt-get install python

To install Python 3.x.x next to your old version, write:

sudo apt-get install python3

Alternatively, you can install the package from Python's website.

Contact

Orakel Support Services can help you install this software. If you encounter problems with your Python code, you can talk to your student assistant in the course.