Python
Definition¶
Python is a high-level, general-purpose programming language.
Python on Euler¶
On Euler the following versions of Python are available through modules:
| Version | Module command |
|---|---|
| 3.9.18 | module load stack/2024-06 python/3.9.18 |
| 3.9.18 with CUDA support | module load stack/2024-06 python_cuda/3.9.18 |
| 3.10.13 | module load stack/2024-06 python/3.10.13 |
| 3.11.6 | module load stack/2024-06 python/3.11.6 |
| 3.11.6 with CUDA support | module load stack/2024-06 python_cuda/3.11.6 |
| 3.12.8 | module load stack/2024-06 python/3.12.8 |
A list of the installed python packages is available here: Python_on_Euler_(Ubuntu)
Package installation¶
- Pip is the package installer for Python. You can use pip to install packages from the Python Package Index and other indexes.
- Conda is an open source package management system and environment management system for installing multiple versions of software packages and their dependencies.
- uv is an extremely fast Python package and project manager, written in Rust.
- distutils is deprecated!
You can install packages locally into "$HOME/.local" using pip via
pip install --user
or you can install them into a virtual environment, which allows for better isolation of the packages, via
python -m venv
source/bin/activate
pip install
To give the virtual environment access to the system site-packages dir, where many packages are already installed, use
python -m venv --system-site-packages
Interactive session¶
Execute "module load stack/2024-06 python/3.11.6" to makes Python available in your command line. Then "python" launches an interactive session. You should see
>>>
and you can try one of Python's easter eggs by writing
>> import this
and pressing enter.
Quit the session by writing "quit()" and enter.
Example Program¶
Create a file "hello.py", containing
print("Hello, World!")
Bring python to your command line with "module load stack/2024-06
python/3.11.6".
Run the program via
python hello.py
and the program should print
Hello, World!
to your terminal.