conda cheatsheet: manage Anaconda package like pro
conda is the command-line interface tool for managing installations of various packages in Anaconda. Of course, Anaconda has GUI to manage everything. But GUI does not provide all the functionalities. Here comes the
conda CLI tool for managing Anaconda packages.
conda basic commands
conda clean --allIt clean tarballs garbage create by environments and clean disk space
conda update <package_name>update a package inside the environment
conda listlist packages inside the environment
conda install -n <env_name> pandasInstall package into an environment from default shell
pip install <package_name>Install a package from the python repo in the current environment.
conda install pandas=0.24.1install package inside an environment
conda Environment commands
conda env listlist the available environments
conda create --name <env_name> pythonCreate conda environment
conda create -n <env_name> python=3.7Create a environment based on Python 3.7
conda activate <env_name>Activate the environment
conda deactivateDeactivate the current environment
To reproduce the project including environment conda has environment files. conda calls it environment files.
conda env export --file environment.ymlexport the current environment to the current working directory
conda env create -n <env_name> environment.ymlrecreate an environment from the environment file form current directory
Note 1: If a package is not available on Anaconda Repository it can be installed from the python default repository using pip. It is also mentioned that pip does not possess all the features of conda packages.
Note 2: It is recommended to install all the packages we want to include in an environment at the time of environment creation. It helps avoid dependency conflicts.
Add conda environment to jupyter notebook
conda create --name myEnv
conda activate myEnv
conda install -c anaconda ipykernel
python -m ipykernel install --user --name=myEnv