0% found this document useful (0 votes)
182 views

Ubuntu22.04 Install Python3.9 How-To

The document shows the steps to install Python 3.9 from source on a Linux system. It installs build tools and dependencies, downloads and compiles the Python source code, and configures Python versions using update-alternatives.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
182 views

Ubuntu22.04 Install Python3.9 How-To

The document shows the steps to install Python 3.9 from source on a Linux system. It installs build tools and dependencies, downloads and compiles the Python source code, and configures Python versions using update-alternatives.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

root@L14VM1:~# sudo apt install build-essential zlib1g-dev libncurses5-dev


libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget
libbz2-dev -y

2.root@L14VM1:~# wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz

3.root@L14VM1:~# tar -xvf Python-3.9.7.tgz

4.root@L14VM1:~# cd Python-3.9.7/

5.root@L14VM1:~# ./configure --enable-optimizations

6.root@L14VM1:~# make

7.root@L14VM1:~# sudo make altinstall

8.root@L14VM1:~# python3.9 --version

9.root@L14VM1:~# which python3.9

root@L14VM1:~# update-alternatives --install /usr/bin/python3 python3


/usr/bin/python3.10 1
update-alternatives: using /usr/bin/python3.10 to provide /usr/bin/python3
(python3) in auto mode

root@L14VM1:~# update-alternatives --install /usr/bin/python3 python3


/usr/local/bin/python3.9 2
update-alternatives: using /usr/local/bin/python3.9 to provide /usr/bin/python3
(python3) in auto mode

update-alternatives --list python3


/usr/bin/python3.10
/usr/local/bin/python3.9

10.root@L14VM1:~# update-alternatives --config python3


There are 2 choices for the alternative python3 (providing /usr/bin/python3).

Selection Path Priority Status


------------------------------------------------------------
* 0 /usr/local/bin/python3.9 2 auto mode
1 /usr/bin/python3.10 1 manual mode
2 /usr/local/bin/python3.9 2 manual mode

Press <enter> to keep the current choice[*], or type selection number: 2


root@L14VM1:~#

root@L14VM1:~# python3 --version


Python 3.9.7

root@L14VM1:~# python3
Python 3.9.7 (default, Oct 30 2022, 10:35:47)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
11.root@L14VM1:/home/srdjan# curl https://bootstrap.pypa.io/get-pip.py -o get-
pip.py

12.srdjan@L14VM1:~$ pip --version


pip 22.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

# Miniconda

Download https://docs.conda.io/en/latest/miniconda.html#linux-installers

bash Miniconda , odabereš yes

(base) srdjan@L14VM1:~$ conda create -n radkit -y python=3.9

#
# To activate this environment, use
#
# $ conda activate radkit
#
# To deactivate an active environment, use
#
# $ conda deactivate

Retrieving notices: ...working... done


(base) srdjan@L14VM1:~$ conda activate radkit
(radkit) srdjan@L14VM1:~$ python3 -m pip install \
--extra-index-url https://radkit-internal.cisco.com/pip/ \
cisco_radkit_client cisco_radkit_service
Looking in indexes: https://pypi.org/simple, https://radkit-internal.cisco.com/pip/
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at
0x7fe2b52bc400>: Failed to establish a new connection: [Errno -2] Name or service
not known')': /pip/cisco-radkit-client/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at
0x7fe2b52bc820>: Failed to establish a new connection: [Errno -2] Name or service
not known')': /pip/cisco-radkit-client/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at
0x7fe2b52bc9d0>: Failed to establish a new connection: [Errno -2] Name or service
not known')': /pip/cisco-radkit-client/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at
0x7fe2b52bcb80>: Failed to establish a new connection: [Errno -2] Name or service
not known')': /pip/cisco-radkit-client/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at
0x7fe2b52bcd30>: Failed to establish a new connection: [Errno -2] Name or service
not known')': /pip/cisco-radkit-client/
ERROR: Could not find a version that satisfies the requirement cisco_radkit_client
(from versions: none)
ERROR: No matching distribution found for cisco_radkit_client
(radkit) srdjan@L14VM1:~$ python3
Python 3.9.13 (main, Oct 13 2022, 21:15:33)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

###### CONDA HOW TO ####

https://conda.io/projects/conda/en/latest/user-guide/install/linux.html

# Da conda ne pravi (base)


conda config --set auto_activate_base false

srdjan@L14VM1:~$ conda create -n radkit -y python=3.9

srdjan@L14VM1:~$ conda activate radkit


(radkit) srdjan@L14VM1:~$ conda deactivate
srdjan@L14VM1:~$

conda clean --all # clear unused

# RadKIT install Option 2 - PREFERRED!

##### Install from whells https://radkit.cisco.com/docs/pages/start_pip_wheels.html


#############

1.Download from https://radkit.cisco.com/downloads/release/1.3.1/


cisco_radkit_1.3.1_pip_linux.tgz

2.Then, unpack the archive into a dedicated directory and make sure it contains all
the .whl files from the archive:

# To extract the archive (on Linux or macOS)


mkdir wheels_dir
cd wheels_dir
srdjan@L14VM1:~/radkit/wheels_dir$ ls
cisco_radkit_1.3.1_pip_linux.tgz

srdjan@L14VM1:~/radkit/wheels_dir$ tar -xvf cisco_radkit_1.3.1_pip_linux.tgz


./
cisco_radkit_genie-1.3.1-py37-none-musllinux_1_2_x86_64.whl
cisco_radkit_common-1.3.1-py37-none-linux_armv7l.whl

# On Windows, simply extract the archive to a new folder using the Explorer

3.Activate venv

conda activate radkit

srdjan@L14VM1:~/radkit/wheels_dir$ conda activate radkit


(radkit) srdjan@L14VM1:~/radkit/wheels_dir$

4. Install in venv
(radkit) srdjan@L14VM1:~/radkit/wheels_dir$ python3 -m pip install -f .
cisco_radkit_client cisco_radkit_service
Looking in links: .
Processing ./cisco_radkit_client-1.3.1-py39-none-manylinux2014_x86_64.whl
Processing ./cisco_radkit_service-1.3.1-py39-none-manylinux2014_x86_64.whl
Collecting tabulate
Downloading tabulate-0.9.0-py3-none-any.whl (35 kB)
Collecting httpx
Downloading httpx-0.23.0-py3-none-any.whl (84 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.8/84.8 kB 2.9 MB/s eta 0:00:00

5. Start srvice
(radkit) srdjan@L14VM1:~/radkit/wheels_dir$ radkit-service run

You might also like