Miniconda

Miniconda is next. There are supposedly some decisions to be made. Version of Python, and bit version. Personally, I don’t expect to see a lot of Python 2.x code (2.x has been deprecated). And, if I do I can always create a virtual environment to deal with that. And, so far I have been able to use the latest version of Python for my book exercises. Even upgrading to newer versions in most cases. That’s one thing virtual environments seemingly complicate by the way. And, I see no reason to use a 32-bit version on a 64-bit machine. The latter may be something you will have to do otherwise.

So, download the Python 3.7 version of Miniconda for 64-bit Windows (https://docs.conda.io/en/latest/miniconda.html).

Verify Download

I also copied the SHA256 hash for the installation file from the web site. Then in a cmd window I ran:

??> certutil -hashfile V:\download\Miniconda3-latest-Windows-x86_64.exe SHA256

The result was:

SHA256 hash of V:\download\Miniconda3-latest-Windows-x86_64.exe:
f18060cc0bb50ae75e4d602b7ce35197c8e31e81288d069b758594f1bb46ab45
CertUtil: -hashfile command completed successfully.

And the resulting hash matched that from the conda web site.

But do note that I moved the Win 10 “Downloads” folder to the location above. Yes, another drive partition. So you may wish to run the following instead:

??> certutil -hashfile C:`\Users\%USERNAME%\Downloads\Miniconda3-latest-Windows-x86_64.exe SHA256

Install

I have already created a installation directory on my Dev partition (E:\appDev\Miniconda3). So, double click the installation file to get started. Click “Install anyway” to bypass the Microsoft “it ain’t from the MS app store” warning. And “Next >” to continue. And “I Agree” once you’ve read as much of the License Agreement as you wish to.

Okay for whatever reason, I usually install for all users (possibly because I have multiple accounts on my pc). If that isn’t necessary in your case, click “Next >”. Otherwise select “All Users” before doing so. Provide Admin credentials if needed. I also needed to change the installation location. Do as appropriate in your case.

On the next window, I recommend you leave the default selection (“Register Anaconda as the system Python 3.7”). Your call, but I do recommend leaving it as is. Click “Install”. Once the installation has completed, click “Next >”. I unclicked all the “learn” buttons and clicked “Finish”. You may wish to load one or both of those web sites.

Verify Installation

Check your installation. Click “Start” button, open the “Anaconda” folder, and click “Anaconda Prompt (Miniconda)”. Once the cmd window is open, enter conda list. You should get a list of the packages installed in the default Miniconda base environment. Something like:

(base) C:\Users\bark>conda list
# packages in environment at E:\appDev\Miniconda3:
#
# Name                    Version                   Build  Channel
  asn1crypto                1.2.0                    py37_0
  ca-certificates           2019.10.16                    0
  certifi                   2019.9.11                py37_0
  cffi                      1.13.0           py37h7a1dbc1_0
  chardet                   3.0.4                 py37_1003
  conda                     4.7.12                   py37_0
  conda-package-handling    1.6.0            py37h62dcd97_0
  console_shortcut          0.1.1                         3
  cryptography              2.8              py37h7a1dbc1_0
  idna                      2.8                      py37_0
  menuinst                  1.4.16           py37he774522_0
  openssl                   1.1.1d               he774522_3
  pip                       19.3.1                   py37_0
  powershell_shortcut       0.0.1                         2
  ...

Catch-22

There’s a bit of a an “if, and or but” regarding the conda installation above. If you were to open a cmd prompt (dos box) and run conda list, you’d see something like:

C:\Users\bark>conda list
'conda' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\bark>

You may have wondered about my choice to “Register Anaconda as the system Python 3.7”. This actually prevented conda from being added to the windows %PATH% environment variable. So windows has no way to find the conda executable. That’s why in our verification step above, we opened an “Anaconda Prompt (Miniconda)”. By doing so, Miniconda added the necessary value to the %PATH% variable to ensure the conda command would run at the prompt. But, that entry only works for that given window. Close it and it’s gone. It’s a kinda catch-22 situation. But, VS Code allows us to set the Python version/virtual environment we wish to use for a given workspace. And, then it initializes that virtual environment the first time we run code in a command window. So, I figured there was no good reason to clutter up the %PATH% variable. I have enough junk in it already.

Test conda and Python

Okay, let’s continue by checking that conda and Python work together. We’ll create a small bit of Python code to test.

As mentioned, all too often I expect, I have a drive partition (Dev2, r: in my case) where I put all my coding projects (I consider all the exercises in a single programming book as a project). Each “project” goes into it’s own folder (directory for us old timers). Under that partition I have a folder called ’learn’ that I use for all the book project folders.

So, I have created the directory r:\learn\install. I then created a text file, called test_conda_python.py, with the following line of Python code:

print('Looks like conda and python are working as expected')

Seeing as we’ve already installed VS Code or some other editor, you could use it to create that file.

I opened an Anaconda prompt (Miniconda) from the Start menu. At the prompt I entered:

(base) C:\Users\bark> r:\learn\install\test_conda_python.py

And I got back:

(base) C:\Users\bark>r:\learn\install\test_conda_python.py
Looks like conda and python are working as expected

(base) C:\Users\bark>

Okay, so far so good. Next post we will look at creating a conda environment, setting up a VS Code project, and making the new conda environment the default for VS Code to execute Pythong code files. Followint that for better or worse I am going to install Git, open a GitHub account and commit the workspace, or at least its initial state, to version control (local repository and push to GitHub).

Okay, it’s supper time in my world. Will continue this next time.