Anaconda#
Installation guide#
Download the installer. Find the latest version for your os and get it. For my cases it was
wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.shInstall using
bash Anaconda-latest-Linux-x86_64.shTo update existing version
conda update conda
Getting started#
Check if you have conda
conda --versionBy default conda creates an environment called
basewith latest versions.Activate it with
source /u/mi3se/anaconda3/bin/activatethenconda activate base. Sometimes you might needconda init bashbefore you can runconda activate base.
You can add this directly to your vscode using
F1->Select interpreter->Findif vscode doesn’t recognise itself.Create a new environment named “snakes” that contains Python 3.9,
conda create --name snakes python=3.9Activate the new environment:
conda activate snakesVerify that the snakes environment has been added and is active
conda info --envsCheck is a package is installed
conda search beautifulsoup4If not install it
conda install beautifulsoup4Check to see if the newly installed program is in this environment
conda list
Conda channels#
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html
solving-environment-failed-with-initial-frozen-solve-retrying-with-flexible-solve
conda config -–set channel_priority false
See current channels
conda config --show channelsTo make conda install the newest version of a package in any listed channel
conda config -–set channel_priority falseadd a new channel with highest priority
conda config --add channels new_channel, lowest priorityconda config --append channels new_channel.Default channel might not find some packages. Add conda-forge
conda config --add channels conda-forge
check channel priorities
conda config --describe channel_priority
Virtual environment#
conda env list
# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
# Create the environment from the environment.yml file
conda env create -f environment.yml
# Export your active environment to a new file
conda env export > environment.yml
#remove an environment
conda remove --name myenv --all
# verify it removed
conda info --envs
# create requirments.txt, https://stackoverflow.com/questions/50777849/from-conda-create-requirements-txt-for-pip3
conda list -e > requirements.txt
# can be used to create a conda virtual environment with
conda create --name <env> --file requirements.txt
# or using pip
pip freeze > requirements.txt
# In an activated conda environment I had to use
pip list --format=freeze > requirements.txt
# Then use the resulting requirements.txt to create a pip virtual environment:
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
# update the contents of your environment file
conda env update --prefix ./env --file environment.yml --prune
Warning
Becareful of using pip inside a conda environment, since conda will use the default pip of the OS, not the pip of the ven. So conda will be be unaware of what pip will install.
Source: Using Pip in a Conda Environment, Installing requirements.txt in Conda Environments