At present, the default version of python under CentOS 8 is Python 3.6.8, which is 6 years old. More and more python software needs newer versions, so it is a vital for pretty stable Linux distro to have an easy way to install newer programming languages like python!
Using Conda it is really easy to manage different environments for different python versions!
Conda is an open source package management system and environment management system that runs on Windows, macOS and Linux.
More on Conda – Installing conda command line in various systems with miniconda and create a simple python environment and all Conda tags – https://ahelpme.com/category/software/anaconda/. This article is not intended to introduce the reader with Conda, but to show how easy is to install the newer version of python 3.10 under CentOS 8 and it is easy because of using the Conda package management system!
To summarize, the purpose is to have a user with python 3.10. The user can be an ordinary or administrative one or even root.
Using this method older or newer versions of python may be installed on the same machine (at the same time).
STEP 1) Install the latest Miniconda3
The installation is easy and for more details check out the first link above.
[root@srv ~]# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
--2022-04-24 00:33:53-- https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.131.3, 104.16.130.3, 2606:4700::6810:8303, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.131.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 75660608 (72M) [application/x-sh]
Saving to: 'Miniconda3-latest-Linux-x86_64.sh'
Miniconda3-latest-Linux-x86_64.sh 100%[==================================================>] 72.16M 11.1MB/s in 6.7s
2022-04-24 00:33:59 (10.8 MB/s) - 'Miniconda3-latest-Linux-x86_64.sh' saved [75660608/75660608]
[root@srv ~]# chmod 755 Miniconda3-latest-Linux-x86_64.sh
[root@srv ~]# ./Miniconda3-latest-Linux-x86_64.sh
Welcome to Miniconda3 py39_4.11.0
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
===================================
End User License Agreement - Miniconda
===================================
Copyright 2015-2021, Anaconda, Inc.
All rights reserved under the 3-clause BSD License:
This End User License Agreement (the "Agreement") is a legal agreement between you and Anaconda, Inc. ("Anacon
da") and governs your use of Miniconda.
Subject to the terms of this Agreement, Anaconda hereby grants you a non-exclusive, non-transferable license t
o:
* Install and use the Miniconda.
* Modify and create derivative works of sample source code delivered in Miniconda subject to the Terms of Se
rvice for the Repository (as defined hereinafter) available at https://www.anaconda.com/terms-of-service, and
* Redistribute code files in source (if provided to you by Anaconda as source) and binary forms, with or wit
hout modification subject to the requirements set forth below.
Anaconda may, at its option, make available patches, workarounds or other updates to Miniconda. Unless the upd
ates are provided with their separate governing terms, they are deemed part of Miniconda licensed to you as pr
ovided in this Agreement. This Agreement does not entitle you to any support for Miniconda.
Do you accept the license terms? [yes|no]
[no] >>> yes
Miniconda3 will now be installed into this location:
/home/myuser/miniconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/myuser/miniconda3] >>>
PREFIX=/home/myuser/miniconda3
Unpacking payload ...
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/myuser/miniconda3
added / updated specs:
- _libgcc_mutex==0.1=main
- _openmp_mutex==4.5=1_gnu
- brotlipy==0.7.0=py39h27cfd23_1003
- ca-certificates==2021.10.26=h06a4308_2
- certifi==2021.10.8=py39h06a4308_2
- cffi==1.15.0=py39hd667e15_1
- charset-normalizer==2.0.4=pyhd3eb1b0_0
- conda-content-trust==0.1.1=pyhd3eb1b0_0
- conda-package-handling==1.7.3=py39h27cfd23_1
- conda==4.11.0=py39h06a4308_0
- cryptography==36.0.0=py39h9ce1e76_0
- idna==3.3=pyhd3eb1b0_0
- ld_impl_linux-64==2.35.1=h7274673_9
- libffi==3.3=he6710b0_2
- libgcc-ng==9.3.0=h5101ec6_17
- libgomp==9.3.0=h5101ec6_17
- libstdcxx-ng==9.3.0=hd4cf53a_17
- ncurses==6.3=h7f8727e_2
- openssl==1.1.1m=h7f8727e_0
- pip==21.2.4=py39h06a4308_0
- pycosat==0.6.3=py39h27cfd23_0
- pycparser==2.21=pyhd3eb1b0_0
- pyopenssl==21.0.0=pyhd3eb1b0_1
- pysocks==1.7.1=py39h06a4308_0
- python==3.9.7=h12debd9_1
- readline==8.1.2=h7f8727e_1
- requests==2.27.1=pyhd3eb1b0_0
- ruamel_yaml==0.15.100=py39h27cfd23_0
- setuptools==58.0.4=py39h06a4308_0
- six==1.16.0=pyhd3eb1b0_0
- sqlite==3.37.0=hc218d9a_0
- tk==8.6.11=h1ccaba5_0
- tqdm==4.62.3=pyhd3eb1b0_1
- tzdata==2021e=hda174b7_0
- urllib3==1.26.7=pyhd3eb1b0_0
- wheel==0.37.1=pyhd3eb1b0_0
- xz==5.2.5=h7b6447c_0
- yaml==0.2.5=h7b6447c_0
- zlib==1.2.11=h7f8727e_4
The following NEW packages will be INSTALLED:
_libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main
_openmp_mutex pkgs/main/linux-64::_openmp_mutex-4.5-1_gnu
brotlipy pkgs/main/linux-64::brotlipy-0.7.0-py39h27cfd23_1003
ca-certificates pkgs/main/linux-64::ca-certificates-2021.10.26-h06a4308_2
certifi pkgs/main/linux-64::certifi-2021.10.8-py39h06a4308_2
cffi pkgs/main/linux-64::cffi-1.15.0-py39hd667e15_1
charset-normalizer pkgs/main/noarch::charset-normalizer-2.0.4-pyhd3eb1b0_0
conda pkgs/main/linux-64::conda-4.11.0-py39h06a4308_0
conda-content-tru~ pkgs/main/noarch::conda-content-trust-0.1.1-pyhd3eb1b0_0
conda-package-han~ pkgs/main/linux-64::conda-package-handling-1.7.3-py39h27cfd23_1
cryptography pkgs/main/linux-64::cryptography-36.0.0-py39h9ce1e76_0
idna pkgs/main/noarch::idna-3.3-pyhd3eb1b0_0
ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.35.1-h7274673_9
libffi pkgs/main/linux-64::libffi-3.3-he6710b0_2
libgcc-ng pkgs/main/linux-64::libgcc-ng-9.3.0-h5101ec6_17
libgomp pkgs/main/linux-64::libgomp-9.3.0-h5101ec6_17
libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.3.0-hd4cf53a_17
ncurses pkgs/main/linux-64::ncurses-6.3-h7f8727e_2
openssl pkgs/main/linux-64::openssl-1.1.1m-h7f8727e_0
pip pkgs/main/linux-64::pip-21.2.4-py39h06a4308_0
pycosat pkgs/main/linux-64::pycosat-0.6.3-py39h27cfd23_0
pycparser pkgs/main/noarch::pycparser-2.21-pyhd3eb1b0_0
pyopenssl pkgs/main/noarch::pyopenssl-21.0.0-pyhd3eb1b0_1
pysocks pkgs/main/linux-64::pysocks-1.7.1-py39h06a4308_0
python pkgs/main/linux-64::python-3.9.7-h12debd9_1
readline pkgs/main/linux-64::readline-8.1.2-h7f8727e_1
requests pkgs/main/noarch::requests-2.27.1-pyhd3eb1b0_0
ruamel_yaml pkgs/main/linux-64::ruamel_yaml-0.15.100-py39h27cfd23_0
setuptools pkgs/main/linux-64::setuptools-58.0.4-py39h06a4308_0
six pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_0
sqlite pkgs/main/linux-64::sqlite-3.37.0-hc218d9a_0
tk pkgs/main/linux-64::tk-8.6.11-h1ccaba5_0
tqdm pkgs/main/noarch::tqdm-4.62.3-pyhd3eb1b0_1
tzdata pkgs/main/noarch::tzdata-2021e-hda174b7_0
urllib3 pkgs/main/noarch::urllib3-1.26.7-pyhd3eb1b0_0
wheel pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
xz pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
yaml pkgs/main/linux-64::yaml-0.2.5-h7b6447c_0
zlib pkgs/main/linux-64::zlib-1.2.11-h7f8727e_4
Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
[no] >>> yes
no change /home/myuser/miniconda3/condabin/conda
no change /home/myuser/miniconda3/bin/conda
no change /home/myuser/miniconda3/bin/conda-env
no change /home/myuser/miniconda3/bin/activate
no change /home/myuser/miniconda3/bin/deactivate
no change /home/myuser/miniconda3/etc/profile.d/conda.sh
no change /home/myuser/miniconda3/etc/fish/conf.d/conda.fish
no change /home/myuser/miniconda3/shell/condabin/Conda.psm1
no change /home/myuser/miniconda3/shell/condabin/conda-hook.ps1
no change /home/myuser/miniconda3/lib/python3.9/site-packages/xontrib/conda.xsh
no change /home/myuser/miniconda3/etc/profile.d/conda.csh
modified /home/myuser/.bashrc
==> For changes to take effect, close and re-open your current shell. <==
If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false
Thank you for installing Miniconda3!
The installation is just a couple of questions about where to install it. The installation is under Linux user myuser, but it can be under any user even without administrative privileges.
Log off and log in to enable the Conda environment.
Last login: Sun Apr 24 15:10:48 UTC 2022 on pts/0 (base) [myuser@srv ~]$
There is an additional “(base)” next to the console command prompt.
STEP 2) Install python 3.10 and use the environment.
Install the python 3.10 by creating a python 3.10 environment and activate it when the user want to use python 3.10:
(base) [myuser@srv ~]$ conda create --name mypython310 python=3.10
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.11.0
latest version: 4.12.0
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: /home/myuser/miniconda3/envs/mypython310
added / updated specs:
- python=3.10
The following packages will be downloaded:
package | build
---------------------------|-----------------
bzip2-1.0.8 | h7b6447c_0 78 KB
ca-certificates-2022.3.29 | h06a4308_1 122 KB
certifi-2020.6.20 | pyhd3eb1b0_3 155 KB
libuuid-1.0.3 | h7f8727e_2 17 KB
openssl-1.1.1n | h7f8727e_0 2.5 MB
pip-21.2.4 | py310h06a4308_0 1.8 MB
python-3.10.4 | h12debd9_0 24.2 MB
setuptools-61.2.0 | py310h06a4308_0 1019 KB
sqlite-3.38.2 | hc218d9a_0 1.0 MB
tzdata-2022a | hda174b7_0 109 KB
zlib-1.2.12 | h7f8727e_2 106 KB
------------------------------------------------------------
Total: 31.1 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main
_openmp_mutex pkgs/main/linux-64::_openmp_mutex-4.5-1_gnu
bzip2 pkgs/main/linux-64::bzip2-1.0.8-h7b6447c_0
ca-certificates pkgs/main/linux-64::ca-certificates-2022.3.29-h06a4308_1
certifi pkgs/main/noarch::certifi-2020.6.20-pyhd3eb1b0_3
ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.35.1-h7274673_9
libffi pkgs/main/linux-64::libffi-3.3-he6710b0_2
libgcc-ng pkgs/main/linux-64::libgcc-ng-9.3.0-h5101ec6_17
libgomp pkgs/main/linux-64::libgomp-9.3.0-h5101ec6_17
libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.3.0-hd4cf53a_17
libuuid pkgs/main/linux-64::libuuid-1.0.3-h7f8727e_2
ncurses pkgs/main/linux-64::ncurses-6.3-h7f8727e_2
openssl pkgs/main/linux-64::openssl-1.1.1n-h7f8727e_0
pip pkgs/main/linux-64::pip-21.2.4-py310h06a4308_0
python pkgs/main/linux-64::python-3.10.4-h12debd9_0
readline pkgs/main/linux-64::readline-8.1.2-h7f8727e_1
setuptools pkgs/main/linux-64::setuptools-61.2.0-py310h06a4308_0
sqlite pkgs/main/linux-64::sqlite-3.38.2-hc218d9a_0
tk pkgs/main/linux-64::tk-8.6.11-h1ccaba5_0
tzdata pkgs/main/noarch::tzdata-2022a-hda174b7_0
wheel pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
xz pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
zlib pkgs/main/linux-64::zlib-1.2.12-h7f8727e_2
Proceed ([y]/n)? y
Downloading and Extracting Packages
python-3.10.4 | 24.2 MB | ################################################################### | 100%
zlib-1.2.12 | 106 KB | ################################################################### | 100%
openssl-1.1.1n | 2.5 MB | ################################################################### | 100%
setuptools-61.2.0 | 1019 KB | ################################################################### | 100%
certifi-2020.6.20 | 155 KB | ################################################################### | 100%
ca-certificates-2022 | 122 KB | ################################################################### | 100%
tzdata-2022a | 109 KB | ################################################################### | 100%
sqlite-3.38.2 | 1.0 MB | ################################################################### | 100%
bzip2-1.0.8 | 78 KB | ################################################################### | 100%
pip-21.2.4 | 1.8 MB | ################################################################### | 100%
libuuid-1.0.3 | 17 KB | ################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate mypython310
#
# To deactivate an active environment, use
#
# $ conda deactivate
(base) [myuser@srv ~]$
Start using the python 3.10 by:
(base) [myuser@srv ~]$ conda activate mypython310 (mypython310) [myuser@srv ~]$ python -V Python 3.10.4
It is easy and the python 3.1 environment is isolated from the base CentOS 8 packages (and users), so updating the CentOS 8 won’t break the python 3.10 environment, which may be the case if a compilation of python 3.10 way is used instead Conda!
The easiest way to activate python 3.10 by default is just writing the activation line in .bashrc file:
(base) [myuser@srv ~]$ echo "conda activate mypython310" >> .bashrc
After this, every login will activate immediately the python 3.10 environment.