Setting up a python virtual environment.
It is easy, but we usually do not have to do it so often so here we write down how it is done. I recomend using virual environments for all things you do using python.
sudo apt-get update
sudo apt-get install libpython3-dev python3 python3-pip
sudo apt-get install python3-venv
# Add
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
Now you can create a virtual environment
python3 -m venv work-env
To use your environment,
source work-env/bin/activate
To create a a Python virtual environment named env
with access to the global site-packages.
virtualenv --system-site-packages env
On windows
Scripts\activate
This was the bare minimum, for more check out this;
And also this,
Conda/Mamba
If using python for ML tasks or if you want to easily switch between python version do. With conda you can install much more than just Python libraries. You can install entire software stacks.
Conda contains its own virual environment, and has MKL-enabled numpy.
https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html
Conda forge,
conda-forge
is an additional channel from which packages may be installed.
After installation you see this on a aarch64 box,
To activate this environment, use:
micromamba activate /home/olof/mambaforge
Or to execute a single command in this environment, use:
micromamba run -p /home/olof/mambaforge mycommand
If you'd prefer that conda's base environment not be activated on startup,
run the following command when conda is activated:
conda config --set auto_activate_base false
You can undo this by running `conda init --reverse $SHELL`
For resource constrained devices. https://github.com/conda-forge/miniforge/releases/
In conda, activating a virtual env with python 3.9 do
conda create --name myenv python=3.9
(base) olof@Host:~$
conda activate myenv
(myenv) olof@Host:~$
conda list