In this tutorial, I will show the first steps for working with conda tool on Fedora 37.
Conda is an open-source package management system and environment management system that runs on Windows, macOS, Linux, and z/OS. Conda quickly installs, runs, and updates packages and their dependencies. Conda easily creates, saves, loads, and switches between environments on your local computer. It was created for Python programs, but it can package and distribute software for any language., see
the official webpage.
I used the DNF tool to install this tool.
[root@fedora mythcat]# dnf install conda
By default, Conda is configured to activate the base environment when I open a fresh terminal session and you can set it to false.
[mythcat@fedora ~]$ conda config --set auto_activate_base false
For the changes to be applied, run the source command with the .bashrc file as an argument.
[mythcat@fedora ~]$ source ~/.bashrc
After installation, the conda can be activated with the base environment.
[mythcat@fedora ~]$ conda activate
(base) [mythcat@fedora ~]$ conda deactivate
[mythcat@fedora ~]$
Let's start a new project environment named test001 with this command:
[mythcat@fedora ~]$ conda create -n test001 python=3.9
...
zlib pkgs/main/linux-64::zlib-1.2.12-h5eee18b_3
Proceed ([y]/n)? y
Downloading and Extracting Packages
libffi-3.3 | 50 KB | ##################################### | 100%
...
setuptools-63.4.1 | 1.1 MB | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate test001
#
# To deactivate an active environment, use
#
# $ conda deactivate
The next step is to activate this with the next command and list installed packages in a conda environment.
[mythcat@fedora ~]$ conda activate test001
(test001) [mythcat@fedora ~]$ conda list
If you want to see all environments then use the next command:
(test001) [mythcat@fedora ~]$ conda env list
# conda environments:
#
test001 * /home/mythcat/.conda/envs/test001
base /usr
The basic usage of conda is to install packages, you can see how to install the scipy package with the next command:
(test001) [mythcat@fedora ~]$ conda install scipy
Using the conda tool.
Also, you can update a package like the pip tool, see the next command:
(test001) [mythcat@fedora ~]$ conda update
CondaValueError: no package names supplied
# Example: conda update -n myenv scipy
You can deactivate/deactivate the environment with these commands:
(test001) [mythcat@fedora ~]$ conda deactivate
[mythcat@fedora ~]$ conda activate test001
(test001) [mythcat@fedora ~]$
You can export the conda environment into YML file type:
(test001) [mythcat@fedora ~]$ conda env export > test001.yml
(test001) [mythcat@fedora ~]$ ls test001.yml
test001.yml
With this file, you can create a new environment in another area, and see the next commands for deactivating and creating the new environment.
(test001) [mythcat@fedora ~]$ conda deactivate
[mythcat@fedora ~]$ ls
Desktop Downloads Music Public test001.yml
Documents kernel-tests Pictures Templates Videos
[mythcat@fedora ~]$ conda env create -f test001.yml
CondaValueError: prefix already exists: /home/mythcat/.conda/envs/test001
Because I try to create in the same place as the old environment I got this error.
You need to use the YML file in another place.
Another option is to clone one environment.
[mythcat@fedora ~]$ conda create --name test001_new_clone --clone test001
Source: /home/mythcat/.conda/envs/test001
Destination: /home/mythcat/.conda/envs/test001_new_clone
Packages: 34
...
You can see all environments with this command:
[mythcat@fedora ~]$ conda info --env
# conda environments:
#
test001 /home/mythcat/.conda/envs/test001
test001_new_clone /home/mythcat/.conda/envs/test001_new_clone
base * /usr
These commands shown are just the beginning of working with the conda utility. It has many more development options.