What it means - "Register Anaconda as my default Python"?

Viewed 629

During installation process (Windows OS) I have 2 options:

  • Add Miniconda to my PATH environment variable
  • Register Miniconda as my default Python

The first option is pretty obvious. I understand it completely. But what about the second? What is meant by the word "register"?

It creates the file with the string "Ok I have registered your Python"or what? What specific operations will be performed? It's so confusing. I have read the whole documentation on their site, but I couldn't find anything about this.

2 Answers

I've investigated this issue today and revealed the secret within. You mean the following Anaconda installer UI, right?

Anaconda3 installer: Register Anaconda3 as my default Python 3.9

I give my conclusion first. What he says is:

Register Anaconda3 as my default Python 3.9

NOT

Register Anaconda3 as my default Python

That means,

  • he can NOT determine what Python version, 3.5, 3.8 or 3.9, becomes your default version.
  • He can only determine that: If the Python Launcher(py.exe), at one run, determines that 3.9 should be used, py.exe should choose Anaconda's Python 3.9 instance.

I verify my conclusion using Anaconda3-2022.05-Windows-x86_64.exe using a series of experiments.

EXP.0 : Preparation

Write a t3.py with content:

#!/usr/bin/python3

import sys
print(sys.executable)

This, when run, will show us which python.exe is being used.

Install python.org official(just call it 'official' for brevity) python-3.5.4.exe, with default options. We'll get a regkey

[HKCU\SOFTWARE\Python\ PythonCore \3.5-32]

and python.exe location is registered there.

Python 3.5 official regkey location.

According to PEP-514, PythonCore is the "company name" chosen by python.org for itself.

Now, run t3.py, we see that this very Python 3.5 is used.

Official py35 used

EXP.1 : Add Anaconda over official 3.5

Now, install Anaconda, ticking the "Register 3.9" option, I install it to d:\Anaconda3. Then we see two regkeys are created.

First, [HKCU\SOFTWARE\Python\ContinuumAnalytics\Anaconda39-64], this marks Anaconda's own Python instance.

Second, [HKCU\SOFTWARE\Python\PythonCore\3.9], this pretends that an official Python instance is installed. Due to this, t3.py now says d:\anaconda3\python.exe is used.

Anaconda adds regkey

Anaconda py39 used

Yes, If we didn't tick the "Register 3.9" option, the [HKCU\SOFTWARE\Python\PythonCore\3.9] regkey will not be created, so Anaconda will not be chosen by py.exe .

EXP.2 : Add Anaconda over official 3.5 & 3.10

Now go back to EXP.0 state -- I personally use a VM and revert to EXP.0 snapshot.

We install an official python 3.10 , followed by installing Anaconda, still ticking "Register 3.9" option.

Then what will happen to t3.py?

The answer is,

C:\Users\chj\AppData\Local\Programs\Python\ Python310 \python.exe

Checking the registry again, the 3.9 (marked as orange) node is still created by Anaconda installer, but it is not picked by py.exe as the default version.

Apparently, py.exe picks the latest version number.

py.exe picks the latest version number as default

EXP.3 : Anaconda installer BUG

Things are not over. If we already have official Python 3.9, and we got further install Anaconda(providing his own 3.9), then what happens?

Anaconda will first kindly prompt us he will overwrite the 3.9 pointer, which looks quite reasonable according to EXP.1 and EXP.2 .

Anaconda warns to overwrite 3.9 pointer

However, after installing, t3.py shows the default 3.9 still points to the official one, Anaconda's overwriting does NOT take place. Hmm, apparently, that's BUGGY.

When you do python file.pyin a shell, windows will use the base version(not miniconda) but when you click it, it will use the miniconda's python. Should you do it? That is up to you, however Anaconda recommend's to check it

Related