Python Engineer

Free Python and Machine Learning Tutorials

Become A Patron and get exclusive content! Get access to ML From Scratch notebooks, join a private Slack channel, get priority response, and more! I really appreciate the support!

Anaconda Tutorial - Installation and Basic Commands

08 Dec 2019

Anaconda is a free Python distribution specifically designed for scientific computing (data science, machine learning). Anaconda let's you easily manage multiple Python environments and simplifies package management.

Why multiple environments

Install

Go to https://www.anaconda.com/distribution and download the latest installer for your machine. Follow the setup instructions.

Get started

General

Check version:

conda --version

Check more information:

conda info

Update conda:

conda update conda

Manage environments

Create a virtual environment:

conda create -n myenv

Specify a specific Python version:

conda create -n myenv Python=3.7

Specify specific packages that are installed:

conda create -n myenv Python=3.7 numpy matplotlib

Activate it (Depending on your machine):

conda activat myenv

source activate myenv
Your terminal will feature the current activated environment.

Deactivate it (Depending on your machine):

conda deactivate

source deactivate

List all environments:

conda env list

Remove a specific environment:

conda env remove -n myenv

Manage packages

Install specific packages:

conda install numpy

Install multiple packages with one command:

conda install seaborn matplotlib pandas

Deinstall packages:

conda remove numpy

List all packages in an environment:

conda list

Update a package:

conda update numpy

Search for packages :

conda search numpy

Installing with pip is also possible:
pip install numpy

It is recommended to install pip in your environment and then use your local pip version. Otherwise it will try to fall back to other ones on the machine
conda install pip
pip install numpy

Conda and Visual Studio Code

Conda integrates nicely into VS Code. It can automatically detect your available conda environments and let's you specify which one you want to use.