conda - a virtual environment manager
How to use conda package manager.
What is conda ?
condais a python package, written in python- it helps you to create virtual environments
How is it different ?
- Python - In
condayou can also chose the version of the python you want. It will then download the version of python that you asked for and then install it for your virtual environment. - Channels - Conda channels are the locations where packages are stored.
You can have multiple channels from where you can get
packages, and you can set there priority. Also they are prebuilt
packages, so you won’t have to compile the whole package yourself.
Some famous channels are -
conda-forgeanaconda - History/Revisions - whenever you make some change to the environment it is stored as a revision to the environment, and if you want to revert back to a previous revision you can do that.
How to install packages ?
In conda environment you can install packages using normal pip,
that will download the latest version of packages that your
according the python you selected.
To install packages using conda you can use conda install pkgname.
This will install packages form the conda repository.
There are channels in conda, each channel is connected to a
specific repository for packages.
What happens when you do conda install
When you do conda install, conda first look for the channels to which it have to search in, then it check for other dependencies and conflicts and find a suitable match which package to install, which package to upgrade and which to downgrade to meet the user need.
This take more time if the metadata is more and more packages are installed in an environment through conda. So it is advised to install all the packages in the starting when creating an environment.
Some sample commands
conda activate- activate the default base environmentconda activate envname- activate theenvnameenvironmentconda deactivate- deactivate the active environmentconda config --set auto_activate_base false- this will create a.condarcfile in the home directory and then add this option there. This option will stop the base environment form activating automatically every time you start a shell.conda create --name env- create a environment with name envconda create -n temp python=3.4- crete a env temp with python 3.4 versionconda list- List linked packages in a conda environment.conda info- Display information about current conda install.conda info -e- Display information about all the conda env.conda install -c channel-name pkginstallpkgform channelchannel-nameconda install ipykernel- install ipykernel in current env so we can open it in jupiter notebook.conda update --all --yes- update all packagesconda remove --name env --all- removeenvpackageconda config --show channels- show list of channels for current envconda config --show default_channels- show default channelsconda config --add channels channel-name- add channelchannel-nameto current envconda config --get channels- show channels and there priority also.conda config --set channel_priority strict- set the channel priority to strictconda list --revision- show the list of revisions a env haveconda search -f pkg- search for a package in conda.conda clean- Remove unused packages and caches.