In this, we learn how to set up a conda environment in few steps (without much talking!).
-
Download the anaconda installer for your OS.
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh -
Install by executing the following commans -
sh <downloaded_path>/Anaconda3-2020.02-Linux-x86_64.sh -
The installer prompts “In order to continue the installation process, please review the license agreement.” Click Enter to view license terms.
-
Scroll to the bottom of the license terms and enter “Yes” to agree.
-
Install in the deafult location.
-
The installer prompts “Do you wish the installer to initialize Anaconda3 by running conda init?” We recommend “yes”.
-
Close and open your terminal window for the installation to take effect, or you can enter the command
source ~/.bashrc
For more details, follow this tutorial : https://docs.anaconda.com/anaconda/install/linux/
-
Verify conda installed or not -
conda --version -
Create a new environment (with a specific python version) -
conda create --name <venv_name> python=<python_version> -
To see the list of environments -
conda info --envs -
Activate the base environment -
conda activate -
Activate the specific environment you just created -
conda activate <venv_name> -
To search a specific python package available or not -
conda search <python_package_name> -
To install specific python package in conda -
``conda install <python_package_name>=<package_version>
-
To view list of python packages installed -
conda list -
To remove a conda environment -
conda env remove --name <env_name> -
To export a conda environment (the second command only consider the packages you have installed and not the transitive dependencies) -
conda env export > environment.ymlconda env export --from-history > environment.yml -
To create a conda environment from environment file -
conda env create -f environment.yml
References: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#more-information
-
Install jupyter notebooks-
conda install -c conda-forge notebookconda install -c conda-forge nb_conda_kernels -
Install jupyter lab -
conda install -c conda-forge jupyterlabconda install -c conda-forge nb_conda_kernels -
Install jupyter notebook extensions -
conda install -c conda-forge jupyter_contrib_nbextensions -
Running the following command will create a kernel that can be used to run jupyter notebook commands inside the virtual environment -
ipython kernel install --user --name=<venv_name> -
Select the installed kernel when you want to use jupyter notebook in this virtual environment
References: https://www.geeksforgeeks.org/using-jupyter-notebook-in-virtual-environment/, https://towardsdatascience.com/how-to-set-up-anaconda-and-jupyter-notebook-the-right-way-de3b7623ea4a