A virtual environment is an isolated copy of your environment that maintains its own version of the language, packages, and versions. It can help in avoiding version conflicts and dependency issues among projects. Anaconda provides a convenient way to manage packages and different environments needed for data science projects. It also helps in creating and managing virtual environments which makes working on different projects much easier. It comes with conda, python, R and over 150 scientific packages.
Conda is the package and environment manager. It is similar to pip, which is the default package manager for python libraries. Conda is more focused on data science packages. One thing to consider is that all the Python packages are not available in anaconda distribution and if you want to install those packages you can use pip for it.
Commands for managing environments
conda create -n env_name
Here, -n is an indicator for the name. It will create an environment named env_name. If we want to create an environment with a specific python version, we can use
conda create -n env_name python=3.0
conda env list
It will list all the environments present in your anaconda setup. Current environment will be marked by an asterisk(*)
conda activate env_name
It will activate the mentioned environment. If we install any package in this environment, it will be available only in this environment.
It will list all the packages installed in the current environment. If you want to check for some other environment that is not activated, you can use
conda list -n env_name
To check if a specific package, we can use conda list -n env_name package_name
conda install package_name
To install any particular package_name. We can also install multiple packages at a time by using
conda install package_name1, package_name2, package_name3
We can also specify any particular version to install using
conda install package_name=version_number
conda remove package_name
To remove any package from the current environment
conda update package_name
It will update the package in the current environment. If we want to update all the packages, we can use
conda update --all
conda search *string*
If we don’t know the exact name for any package, then we can search for it. It will give you all the related package names.
It will deactivate the current environment.
conda env remove -n env_name
It will remove the mentioned environment.
pip freeze &amp;amp;amp;gt; requirements.txt
It saves a list of all the installed packages in the requirements.txt file. It can be used to save the requirements of your projects for the future.
pip install -r requirements.txt
It will install all the packages and versions mentioned in the requirements.txt. It can be useful in running others or past projects.
It is a good practice to create separate environments for different projects and work in it. It might seem a little bit confusing in the beginning but with practice, it will become much easier.
I am doing Udacity deep learning nanodegree program and trying to maintain notes in the blog format. Also, you can find these details and other commands on the Anaconda official document page.