Official Python #
Tip
DTU recommends using version 3.11 of Python.
It is recommended to not have more Python versions installed (unless you feel confident in selectively using explicit versions).
We suggest removing any pre-installed Python versions before proceeding with this guide to ensure a smooth installation process. For help with this process, take a look at this section.
Download & Installation#
Do not install Python 3.12 or later
For the time being, we recommend not downloading version 3.12 (or later) of Python. This is because some of the course dependencies does not yet work with said versions.
Installing Python through the App Store is by far the easiest!
Search for Python in the store and select a suitable version (for instance this).
Alternatively you can open a terminal (press Win-R, type cmd
and Enter) then type python
and
Enter which should open up the App store where Python can be selected, remember to select the correct version!
However, if you find yourself on an adventurous detour and can’t access it there, you can still opt for the official Python release.
Download the 64bit version.
Just remember to check the Add Python to PATH box (at the bottom of the installation GUI).
Launch a terminal (press Command-Space), and execute the following code:
_TMP_FILE=$(mktemp) && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | tee >(grep "brew shellenv" | tee $_TMP_FILE) && eval "$(cat $_TMP_FILE)" && (echo; cat $_TMP_FILE >> $HOME/.profile) && brew install python
Press Enter, and after some moments it will ask you to Press RETURN/ENTER again. Once done, you will have Homebrew and Python.
See here for more details on Homebrew.
You can download the official python directly from here. After downloading the installer, the installation process should be relatively straightforward.
Once installed, check it works. If it doesn’t and you have an M1/M2/MX processor, you might need to use Rosetta to enable it:
Rosetta 1 or 2.
You can figure this out by pressing the Apple icon (top left)
and then About this Mac
/Om denne Mac
.
If there are problems, a more detailed instruction can be found here.
If you still have problems, please contact us at pythonsupport@dtu.dk.
Almost all Linux distributions ships a Python at its core. If not, use your distributions package manager to install Python
Something like:
# the exact package manager, or package name is distro dependent
sudo apt install python3
Installing packages#
Unsure what a terminal is?
Please head over here to understand how to open and use a terminal.
Using this installation will require you to use pip (see link for more details). Open up a terminal and run the following:
python -m pip install numpy
python3 -m pip install numpy
python3 -m pip install numpy
Replace numpy
by the package name you wish to install.
Seeing (mach-o file, but is an incompatible architecture ...
?
If you get the error message ending in
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))``,
Then run the following command:
pip install --upgrade --force-reinstall numpy
pip3 install --upgrade --force-reinstall numpy
pip3 install --upgrade --force-reinstall numpy