Skip to content

Instantly share code, notes, and snippets.

@UbuntuEvangelist
Last active April 17, 2024 01:29
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save UbuntuEvangelist/fe805176e61d927d11b139166bdbfd6d to your computer and use it in GitHub Desktop.
Save UbuntuEvangelist/fe805176e61d927d11b139166bdbfd6d to your computer and use it in GitHub Desktop.
This Commands Will Install Multiple Python-3.11.x Into Ubuntu 22.04 LTS
# !/bin/sh
# Install Python 3 on Ubuntu From Source
sudo -i
apt update && apt upgrade -y
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
apt install build-essential checkinstall
apt autoremove
apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
cd /opt
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
tar xzf Python-3.11.0.tgz
rm -f Python-3.11.0.tgz
cd Python-3.11.0
./configure --enable-optimizations
make altinstall
apt install python3-pip
cd
nano ~/.bashrc
# Add into the bottom
alias python=python3
alias pip=pip3
# Save & Exit ctrl+s and ctrl+x
alias python=python3
alias pip=pip3
source ~/.bashrc
sudo apt update
sudo apt upgrade -y
python --version
pip --version
# Install Python using PPA
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12
# Switch Python version
update-alternatives --config python3
@constantinedev
Copy link

nice update

@UbuntuEvangelist
Copy link
Author

@constantinedev thanks 🐧

@coderhard
Copy link

How does this upgrade to 3.9 when it explicitly states 3.10?

> wget https://www.python.org/ftp/python/3.10.7/Python-3.10.7.tgz
> tar xzf Python-3.10.7.tgz
> rm -f Python-3.10.7.tgz
> cd Python-3.10.7

That being said changing the 10.7 to 9.9 resolves the problems.

@UbuntuEvangelist
Copy link
Author

UbuntuEvangelist commented Apr 9, 2023

@coderhard Thanks
just update

Screenshot from 2023-04-10 01-36-21
Screenshot from 2023-04-10 01-36-43
Screenshot from 2023-04-10 01-36-52
Screenshot from 2023-04-10 01-36-55

@hunterserror
Copy link

i did here every thing in this gist but problem is i can't switch 1 python version to another version python so i found some error like cd /opt download python update version into this and after i install into this folder but everything goes well when i use switch command showing update-alternatives: error: no alternatives for python3....... so i linked /usr/bin/python3 python3 /opt/python3.10. 1 then its work. so i am facing another problem now my python version not showing LoL so i am trying to solve it...
Happy error hunting

image

@UbuntuEvangelist
Copy link
Author

i did here every thing in this gist but problem is i can't switch 1 python version to another version python so i found some error like cd /opt download python update version into this and after i install into this folder but everything goes well when i use switch command showing update-alternatives: error: no alternatives for python3....... so i linked /usr/bin/python3 python3 /opt/python3.10. 1 then its work. so i am facing another problem now my python version not showing LoL so i am trying to solve it... Happy error hunting

image

If Python version switching is working and you can select multiple version python your setup it ready to go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment