Home

Essential Commands for Python Development

Conda-Logo

Introduction

In this blog post, we’ll explore the essential Conda commands that every Python developer should know. these commands were put together as they were ther ones I most frequently used.

Anaconda vs. Miniconda: A Quick Comparison

Anaconda is a full distribution that includes Python, Conda, and a plethora of pre-installed packages suited for scientific computing, data science, and machine learning. It’s ideal for those who prefer an out-of-the-box solution but comes at the cost of a larger disk space requirement.

On the other hand, Miniconda is a minimalistic version, including only Python and Conda. It’s lightweight and gives you the flexibility to install only the packages you need, making it a preferred choice for minimalists and advanced users who want more control over their development environment.

1. Installing Conda

Before diving into the commands, ensure you have Conda installed, whether its Anaconda or Miniconda the commands will remain the same. You can install it as part of the Anaconda distribution, which includes Python, Conda, and commonly used packages and tools.

2. Creating a New Environment

To create a new environment, use:

conda create --name myenv

You can also specify the Python version, and include packages and channels:

conda create --name myenv python=3.8 numpy pandas scikit-learn -c conda-forge

3. Activating an Environment

To activate your Conda environment, use:

conda activate myenv

4. Deactivating an Environment

To deactivate the current environment and revert to the base environment, use:

conda deactivate

5. Listing Environments

To see a list of all your environments, use:

conda env list

or

conda info --envs

6. Listing Installed Packages

To list all packages installed in the active environment, use:

conda list

7. Installing Packages

To install a specific package, such as NumPy, use:

conda install numpy

You can also install multiple packages at once:

conda install numpy scipy pandas

And specify the version of a package:

conda install numpy=1.18

8. Updating Packages

To update a specific package, use:

conda update numpy

To update Python, use:

conda update python

To update Conda itself, use:

conda update conda

9. Removing Packages and Environments

To remove a package, use:

conda remove numpy

To remove an environment, use:

conda env remove --name myenv

10. Searching for Packages

To search for a specific package, use:

conda search numpy

11. Saving Environment to a File

To export your environment to a YAML file, use:

conda env export > environment.yml

12. Creating an Environment from a File

To create an environment from a YAML file, use:

conda env create -f environment.yml
Productivity
Published on 28/06/2023, last updated on 28/11/2023