How do I install the specific version of Python 3.8.2 in Colab?

Viewed 445

I have got some experience with Colab running Python 3.7.13. Now i want to run it with Python 3.8.2 for certain compability reason and also install Miniconda3. First I get Python 3.8.13 and at the end I get 3.8.10. But I want to get 3.8.2. What shall I do? The script code I use is as follows:

!sudo apt-get update -y
!sudo apt-get install python3.8
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2

!python --version # See that I have Python 3.8.13

%env PYTHONPATH=

!wget https://repo.anaconda.com/miniconda/Miniconda3-py38_4.10.3-Linux-x86_64.sh 
!chmod +x Miniconda3-py38_4.10.3-Linux-x86_64.sh
!bash ./Miniconda3-py38_4.10.3-Linux-x86_64.sh -b -f -p /usr/local 

import sys 
sys.path.append('/usr/local/lib/python3.7/site-packages/')

!conda update -n base -c defaults conda --yes

!conda --version # Conda version 4.13.0
!python --version # Python version 3.8.10

Note:

  1. With the technique of this script we can get Python 3.9 latest version by change on line 2 and 4 to Python3.9 and below change the Miniconda installation file correspondingly.

  2. A problem with Python 3.8.2 might be that the Miniconda installer files start from Python 3.8.4 and higher. My guess it is easier to downgrade Python from the current installer than upgrade from installer based on Python 3.7.x

  3. A bit ugly is that the sys path appends python3.7 but people who install python 3.9.x do stick to this command so I also did that. But perhaps should be changed.

I badly need Python 3.8.2 installed and no other version, please!

0 Answers
Related