Miniconda Install

Miniconda is an Anaconda based installer, which has a lightweight base Python environment instead of a data science distribution. This base Python environment contains Python 3.11 and the conda package manager which can be used to create Python environments. The conda-libmamba-solver is included with Miniconda which greatly increases its performance.

The conda package manager has two channels:

  • conda: default
  • conda-forge: community channel

The conda-forge channel is the community channel and is maintained directly by project developers. The conda channel is a channel maintained by anaconda developers who test packages for compatibility with their Anaconda Python Distribution. As it takes time to test packages and they only test more popular packages, this channel is usually behind the community conda-forge channel. It is generally more reliable to use the conda-forge channel when creating custom environments.

Unfortunately neither the conda-forge channel or conda-libmamba-solver are enabled by default but can easily be enabled post-installation by a .condarc configuration file.

Miniforge and Mambaforge were modified Miniconda installers that are defaulted to the conda-forge channel and in the case of Mambaforge included the mamba package manager. These installers are outdated on Windows (have old Python versions) and lack some features (using the depreciated CMD instead of PowerShell).

Uninstall

Miniconda may not work as intended when another Anaconda based Python distribution is installed such as Anaconda, Miniconda (including Miniforge, Miniconda).

If you have an old Python installation follow the instructions to Uninstall and Purge old Python Distributions. This will allow Miniconda to be installed properly.

Download

The download link for Miniconda can be found on the Miniconda home page. Select Miniconda3-Windows-64_bit:

img_001

The setup should now be in the Downloads folder:

img_002

Installation

Launch the setup:

img_003

The setup will begin:

img_004

Accept the License Agreement:

img_005

Select just me (recommended):

img_006

The default install location will be in:

%USERPROFILE%\Miniconda3
%USERPROFILE%\Anaconda3

The environmental variable %USERPROFILE% maps to the location of your User Profile, in this case C:\Users\Philip

img_007

Installation options will display:

img_008

A common option the I recommend enabling (although shown as not recommended) is to add Miniconda to the Windows Environmental Variables Path which makes the (base) Python environment available in the Windows Terminal.

Note that leaving this option unchecked may cause a minor issue with VSCode. VSCode uses the Windows Terminal and shows an error message when launching a Python script when the (base) Python environment is not added to the path. If this option has not been checked, Miniconda can be manually added to the Windows Environmental Variables path see:
Adding Miniconda to the Windows Environmental Variables Path.

The reason this option is not recommended by default is it can arise to conflicts when multiple Python distributions are installed/uninstalled. In general it is not recommended to install multiple Python distributions and a better practice to stick to only using Miniconda.

img_009

Select Next:

img_010

Select Finish:

img_011

Exploring the base Python Environment

Miniconda should be installed in:

%UserProfile%/Miniconda3
%UserProfile%/Anaconda3
img_012
img_013

In this folder is a python.exe

img_014

And a Lib subfolder:

img_015

This Lib subfolder contains Python standard modules.

These can be in the form of packages and the folder name is essentially the package name. For example in the case of email:

img_016

In the email folder is a __init__.py which is the initialisation module of the folder:

img_017

Or in the form of a module.py for example datetime.py

img_018

Miniconda PowerShell Prompt

The Miniconda PowerShell Prompt is a Windows PowerShell Prompt that also has access to the conda package manager and supports switching between Python environments:

img_019

This opens a Terminal similar to the Windows Terminal.

(base) indicates that the Miniconda Python base environment is selected.

C:\Users\Philip indicates the file path which is %UserProfile% by default.

> indicates a new prompt.

img_020

The programming language used by the Miniconda Prompt by default is PowerShell. PowerShell is a scripting language that is essentially a terminal based equivalent of Windows Explorer. It is used essentially to navigate around the Operating System.

PowerShell uses a syntax of the form:

command option -p parametervalue1
command option --parametername2 parametervalue2
command option --parametername3

Whereas Python uses the following syntax:

function(value1, arg2=value2)

The Miniconda PowerShell Prompt can be used to invoke Python from the (base) Python environment using:

python
img_021

Details about the Python version in (base) will display. Notice the prompt change from > (PowerShell) to >>> (Python):

img_022

The email package can be imported and the file of its intialisation module viewed using:

import email
email.__file__
img_023

The datetime module can be imported and its file viewed using:

import datetime
datetime.__file__
img_024

To exit Python the function:

exit()

can be used. Notice the prompt returns to > indicating PowerShell.

img_025

To exit PowerShell use the command:

exit
img_026

Notice the differences in the two syntaxes as the two different programming languages are used.

Python uses parenthesis to call functions and enclose any function input arguments. PowerShell, instead uses a space between the command and its input arguments. Do not confuse the two programming languages!

Third-party packages are in the site-packages subfolder

img_027

In the (base) Python environment this includes the conda package manager:

img_028

The packages can be viewed by inputting:

conda list
img_029
img_030

The PowerShell command cls can be used to clear the screen:

cls
img_031

Configuring Channels and Solver

The Miniconda PowerShell Prompt opens in %USERPROFILE% by default:

img_032

This location can be viewed in Windows Explorer:

img_033

A .condarc file can be created in this location to configure to conda-forge select conda-forge as the default channel with a strict channel priority and to use the libmamba solver:

conda config --add channels conda-forge
conda config --set solver libmamba
conda config --set channel_priority strict
img_034

This updates the .condarc file:

img_035

This can be seen by opening it in notepad using:

notepad .condarc
img_036

This has the form:

channels:
   - conda-forge
   - defaults
solver: libmamba
channel_priority: strict
img_037

Updating the (base) Python Distribution

THIS COMMAND SHOULD NEVER BE USED WITH THE ANACONDA PYTHON DISTRIBUTION AS IT WILL LEAD TO AN UNSTABLE BASE PYTHON ENVIRONMENT EFFECTIVELY PURGING THE DATA SCIENCE DISTRIBUTION.

The conda package manager in the Anaconda base distribution can be used as is to make Python environments. The base Python environment should only be updated via a standalone installer when made available (usually bi-annually by Anaconda).

The PowerShell command conda can be used with option and named parameter –all to update all packages:

conda update --all

This will update all packages in the base Python environment.

img_038

Notice that this switches the channel from conda to conda-forge for all packages in the base Python environment. Input y to proceed:

img_039

The base Python environment is now ready:

img_040

And the changes can be seen in Windows Explorer:

img_041

More details can be sen using:

conda list
img_042
img_043

Useful PowerShell Commands

The most commonly used PowerShell commands are:

commandcommand description
cdChange Directory
clsClears the Screen
mkdirMake a Directory
rmdirRemoves a Directory
typeDisplays the contents of a text file

PowerShell can also be used to launch Windows Applications for example:

commandcommand description
notepadlaunches notepad
calclaunches calculator
mspaintlaunches paint

The Miniconda (base) environment also includes:

commandcommand description
condaconda package manager
pythonPython
idleLaunches IDLE

If other IDEs are installed:

commandcommand description
jupyter labLaunches JupyterLab (lab gives the option lab)
jupyterLaunches Jupyter Notebook (legacy)
spyderLaunches Spyder
codeLaunches VSCode

The Miniconda Prompt opens in the environmental variable %USERPROFILE% by default which in my case is C:\Users\Philip.

img_044

Documents is a subfolder and the directory can be changed to Documents using:

cd Documents
img_045
img_046

In PowerShell ~ is a shortcut to the Windows Environmental Variable $USERPROFILE%. The ./ and ../ mean in the same folder as and up a level respectively:

img_047

To clear the screen use:

cls
img_048
img_049

A new Python script file can be created in PowerShell using:

ni script.py
img_050

To list all directories and files use:

ls
img_051

This can be opened in notepad using:

notepad script.py
img_052

The following Python code can be added to the script file using notepad:

print('Hello World!')
img_053

The Python script file can be ran using:

python script.py
img_054
img_055

If the code in the script file is changed to:

import time
time.sleep(5000)
img_056

The console will hang for 5000 seconds while running the script file:

img_057

The keyboard shortcut Ctrl + c is used to close an operation that is running in terminal.

img_058

To copy from the terminal the keyboard shortcut Ctrl + + c is used.

To paste to the terminal the keyboard shortcut Ctrl + + p is used.

Return to Miniconda Installation