How to create a python environment

`Simple Python Version Management with pyenv, see

Python package management with pip (python version 2) or pip3 (python version 3)


$ pip3 install --target $MyPipRepo -r $MyRequirements.txt
$ pip3 install --target /export01/mriqc -r

Creating Virtual Environments, see

… with Anaconda -

Anaconda is better at handling non-python dependencies and it is also well supported. You can download the installer script for your platform and follow instructions. Make sure to
save this installer script in a directory with enough storage as your BIC account storage is limited by a fixed quota. Watch the tutorial and refer to the Quick Start Guide.

Here’s an installation example: set $PREFIX to the location where you want it installed, somewhere with gigabytes available, 10GB or more! Then follow instrutions.

$ bash /tmp/ -p $PREFIX

$ bash /tmp/ -p /export01/conda

if you decide to answer yes towards the end to allow the script to initialize Anaconda3, then you should deactivate (as suggested) conda upon (shell) startup, otherwise it may break other workflows that you use, those that depend on other python versions like an old version of FSL for example. Say no to the initialization phase to avoid this.

to startup anaconda,…

$ source /export01/conda/etc/profile.d/
$ conda -h

there are many possibilities at this stage, but perhaps the next step would be to create an environment, for example:

$ source /export01/conda/etc/profile.d/
$ conda create -n py3env python=3.8
$ conda activate py3env
(py3env) me@work:~$ python --version
Python 3.8.5
(py3env) me@work:~$ conda install spyder
(py3env) me@work:~$ spyder
(py3env) me@work:~$ conda deactivate

other resources:,

1 Like