Installing and starting Python¶
For this course, you will initially need to start the Spyder integrated development environment, and we do most of the work inside this environment.
Later, we will also use Jupyter notebooks.
Minimum installation requirements: Spyder¶
The Spyder project provides a pre-packaged Spyder installation (see
https://docs.spyder-ide.org/current/installation.html#downloading-and-installing)
which brings its own python and collection of libraries we need for this module
(such as numpy
, scipy
, matplotlib
, pandas
, and sympy
).
This provides all the tools you need for the beginning of the course. (The
additional tools you may need later are jupyterlab
and pytest
.)
Full Installation requirements¶
You need to install python (version 3.12 or 3.13 recommended) and the following python packages:
spyder
numpy
scipy
pandas
matplotlib
sympy
ipython
pytest
jupyterlab
If you you know how to do that, go ahead and do it. Then Check your installation.
If you do not know how to do that, read on.
Installation options¶
To install the python packages, there are multiple options:
use packages that your operating system (such as Ubuntu, Debian, …) provides
use dedicated packaging tools such as conda-forge (mini-forge) or pixi to install them
install python (somehow), and use python’s
pip install
to install the packages.
If all of this is new to you, we recommend you try the relatively young pixi project.
Pixi¶
install pixi from https://pixi.sh/
create a subdirectory where you want to store you python files. Let’s assume we call it
py4cs
.open a terminal/shell and navigate to that directory (for example
cd py4cs
)initialise a pixi environment by running
pixi init .
install the required packages with
pixi add python spyder numpy matplotlib sympy pandas ipython pytest jupyterlab scipy
To use the python tools you just installed, you need to type pixi shell
in the
py4cs
directory. Afterwards, you can start python with python
and the Spyder
IDE with spyder
.
Anaconda distribution¶
The use of the anaconda distribution may require paying of license fees. From https://www.anaconda.com/pricing: “Use of Anaconda’s Offerings at an organization of more than 200 employees requires a Business or Enterprise license. “
We recommend you install Spyder by other means.
If you are familiar with conda
, you can use the mini-forge installer from
conda-forge. Or you use pixi to
download the same conda-forge packages.
Check your installation¶
You can download this test-python-installation.py file and run it from the command prompt like this (assuming you have the installed python interpreter in the search path):
python test-python-installation.py
You should see a table of installed packages, looking something like this (it is okay if the version numbers are different):
Running using Python 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:19:53) [Clang 18.1.8 ]
Testing Python version-> Python OK 3.12.8
Testing numpy... -> numpy OK 2.2.0
Testing scipy... -> scipy OK 1.14.1
Testing pandas... -> pandas OK 2.2.3
Testing matplotlib... -> matplotlib OK 3.10.0
Testing sympy... -> sympy OK 1.13.3
Testing pytest... -> pytest OK 8.3.4
Completed 2024-12-20 12:58:57.135614 in 10.7 seconds.