Python Setup with Anaconda

Anaconda is a platform for managing virtual environments and packages for Python and R. Miniconda is a minimal installer for Anaconda, which only contains the necessary packages.

It is important to use virtual environments to separate the development environments of different projects and this is made easy using Anaconda. You can read more about virtual environments here.

Installation

If you just want a normal installation of Anaconda, download the latest executable of Miniconda and install like any other program.

To install Anaconda with minimal changes to your system, follow steps 1-3 below.

1. Download the executable

Download the latest executable of Miniconda.

2. Install with minimal footprint

Rename the file Miniconda3-latest-Windows-x86_64.exe to miniconda.exe and start the installation in the command prompt (cmd):

:: Installation with minimal footprint
miniconda.exe /InstallationType=JustMe /AddToPath=0 /RegisterPython=0 /NoRegistry=1

Follow the instructions and install to an applications folder in your home directory (e.g. C:\Users\<username>\Applications).

3. Add miniconda to Path

Press the Windows key and search for Edit environmental variables for your account. Create or modify the Path variable and add these three entries (use the installation path you chose in step 2):

  • %USERPROFILE%\Applications\miniconda3
  • %USERPROFILE%\Applications\miniconda3\Scripts
  • %USERPROFILE%\Applications\miniconda3\Library\bin

4. Test that it's working

:: Check Anaconda version
conda --version

Should print something like: conda 4.11.0

Update the environment and package paths

Normally, Anaconda stores environments and packages in its own installation folder. This is not ideal if you need to reinstall Anaconda and you can change this behaviour by creating folders for the python environments and packages in your home directory instead and then telling Anaconda where to find them.

Create the folders:

  • C:\Users\<username>\conda\envs
  • C:\Users\<username>\conda\pkgs

Create an empty configuration file for Anaconda, named .condarc, in your home directory:

:: Creat an empty conda configuration file
type NUL >> %USERPROFILE%\.condarc

Open the .condarc file in a text editor and add the following:

envs_dirs:
  - C:\Users\<username>\conda\envs
pkgs_dirs:
  - C:\Users\<username>\conda\pkgs

Update Anaconda

:: Update Anaconda
conda update -n root conda

Create and use a Virtual Environment

:: Create a virtual environment named python-basics
conda create -n python-basics

:: Activate the virtual environment
activate python-basics

Install Python Packages

:: Activate the python-basics environment
activate python-basics

:: Install the packages (eg pandas, numpy, and matplotlib)
conda install pandas numpy matplotlib

or

:: Install pandas, numpy, and matplotlib in the python-basics environment
conda install -n python-basics pandas numpy matplotlib

More from Peter Alping
All posts