This version is outdated by a newer approved version.DiffThis version (2023/02/17 17:51) was approved by msiegel.The Previously approved version (2013/08/29 08:15) is available.Diff

This is an old revision of the document!


Python

Python is comparatively fast evolving programming language, so different versions behave very differently. We provide multiple varieties of python installations, please always use spack to find and load them. On the more recent python versions the following packages are included (eg try import os in python):

  • os
  • sys
  • pathlib
  • subprocess

However, even the newer python modules do not contain other widespread packages like numpy. We installed many packages, pease always use spack to find and load them. Yet there are so many additional python packages, some with long dependency chains, that we cannot really install all of them for all the different python versions. All installed python packages are named as py-mypackagename, like py-numpy or py-scipy. If your desired package is not installed, there might be a package at the conda forge.

Unfortunately pip does not really work reliably on our cluster, please use conda from Anaconda to set up a consistent local python environment. As an example for a package available on the conda forge, which we do not provide via spack, we also install phono3py into our conda environment (myenv) with conda:

conda create -n myenv
conda activate myenv
conda install numpy
conda install phono3py

Conda will load our miniconda image, update a bunch of packages and install phono3py from conda forge:

(myenv)  myname@l51:~$ which python
~/.conda/envs/test/bin/python
(myenv)  myname@l51:~/python$ python --version
Python 3.11.0
(myenv)  myname@l51:~/python$ which phono3py
~/.conda/envs/test/bin/phono3py

Starting python in this conda environment (myenv), and loading the packages also works:

(myenv)  myname@l51:~$ python
Python 3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:27:40) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import phono3py
>>> exit()

When using slurm it should be enough to include the line conda activate myenv in your slurm batch script. See slurm for detailed information about slurm in general.

See jupyterhub for an even cooler way to access VSC, especially when you are using mainly python.

  • doku/python.1676656293.txt.gz
  • Last modified: 2024/10/24 10:21
  • (external edit)