Instalacja Pythona z poziomu użytkownika

Installing a new Python version in your home directory

Step 1: To install a new version of the Python software from the user's level, you must first start the interactive mode:

srun --pty /bin/bash


Step 2. Then we download the software version we are interested in, for example Python-3.9.0

 wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0a6.tgz


Krkok 3: Unpack the package

tar -zxvf Python-3.5.1.tgz


Step 4: Enter the Python source code directory

cd Python-3.9.0a6


Step 5: Run the configure and select the directory where the python will be installed.

./configure --prefix=/home/users/${USER}/python/


Step 6: Compile with installation

make
make install


Step 7: Check the installed version

$ /home/users/${USER}/python/bin/python3 -V
Python 3.9.0


IMPORTANT: Refer to the new python installed in your scripts.

Make sure there is a reference to the new python at the top of each script you write, the first line should look like this:

#!/home/users/${USER}/python/bin/python3


Installation of Python packages from the user level

To install Python packages from the user's level, you must first start the interactive mode:

srun --pty /bin/bash


After receiving the interactive console we load the Python module:

module load python/version


Python packages are installed using pip:

pip install --user package_name


The package will be installed in your home directory:

 /home/users/user_name/.local/lib/python_version/site-packages/


Add the installed package to the Python variable:

export PYTHONPATH=$PYTHONPATH:/home/users/user_name/.local/lib/python_version/site-packages/


The last step is to check if you can import the installed package by running Python and executing the command:

import package_name