Migrating from Anaconda¶
The University of Vienna does not have a license for the official anaconda.inc repositories and employees shall not use these. There are alternatives that are used most of the time anyways.
to Micromamba/Mamba/Miniforge¶
To migrate from Anacondo to Micromamba follow the steps below.
- Export the installed Packages into a yml
conda env export -n <env-name> --no-builds > <env-name>.yml
Make sure your yml doesn't use the defaults channel but conda-forge instead
name: test
channels:
- pkgs/main # replace with conda-forge
dependencies:
- ...
Open the yml file you just created and remove the channel default.
Add the channel conda-forge
. Using both at the same time can lead to problems with the environment.
If you are having trouble installing some packages check anaconda.org for other channels that may have your desired version.
Check if your .condarc file uses the channel default. Even if you remove the channel default from your yaml it is still used if it is specified in your .condarc
- Create the new environment from the yml file
# using micromamba, available on all IMGW servers
micromamba create -n <env-name> --file <env-name>.yml
# or using mamba
mamba env create -n my_new_env -f environment.yml
Remember that you should also remove the conda part in your ~.bashrc
file. e.g.:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/path/to/conda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/path/to/conda/etc/profile.d/conda.sh" ]; then
. "/path/to/conda/etc/profile.d/conda.sh"
else
export PATH="/path/to/conda/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
Remove this! You can add the micromamba shell init if you wish by running: micromamba shell init
to venv¶
- Export the packages into a requirements.txt:
# activate conda environment or use -n or -p options.
conda list -n <env_name> -p <env_path> --export > requirements.txt
- Run the following command to create a new virtual environment:
python -m venv <env-name>
Activate the virtual environment
<env-name>\Scripts\activate
Now that your virtual environment is active, you can install the packages from your Conda environment.
pip install -r requirements.txt
finished.