Skip to content

Instantly share code, notes, and snippets.

@miditkl
Forked from vbe0201/raspberry_python.sh
Last active December 13, 2023 09:30
Show Gist options
  • Save miditkl/cfe29370d2205bd1ad296e7bc7c9b9ea to your computer and use it in GitHub Desktop.
Save miditkl/cfe29370d2205bd1ad296e7bc7c9b9ea to your computer and use it in GitHub Desktop.
A shell script for installing Python 3.10.2 on your Raspberry Pi.
#!/bin/bash
# A bash script for installing Python 3.10.2 on your Raspberry Pi.
# (c) 2022 Valentin B. / Midian T. E.
#
# Open your terminal and type the following command:
# sudo wget https://gist.githubusercontent.com/realSnosh/cfe29370d2205bd1ad296e7bc7c9b9ea/raw/raspberry_python.sh && chmod +x raspberry_python.sh && ./raspberry_python.sh
sudo apt-get update -y
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libc6-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libsqlite3-dev tk-dev libssl-dev openssl libffi-dev -y
mkdir Python-Installation
cd Python-Installation
wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz
tar xzvf Python-3.10.2.tgz
rm -f Python-3.10.2.tgz
cd Python-3.10.2
sudo ./configure --enable-optimizations
sudo make -j 4
sudo make altinstall
cd ../..
sudo rm -rf Python-Installation
sudo apt-get --purge remove build-essential libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libc6-dev libz2-dev libexpat1-dev liblzma-dev zlib1g-dev libsqlite3-dev tk-dev libssl-dev openssl libffi-dev -y
sudo apt-get autoremove -y
sudo apt-get clean
python3.10.2 -m pip install --upgrade pip
sudo echo 'alias python="python3.10.2"' >> ~/.bashrc
sudo echo 'alias pip="python3.10.2 -m pip"' >> ~/.bashrc
source ~/.bashrc
@cfsmp3
Copy link

cfsmp3 commented Feb 26, 2023

Consider doing this to make it the default (and have the system know about it) instead of using aliases

sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 3

@miditkl
Copy link
Author

miditkl commented Mar 1, 2023

@cfsmp3 I'll do an update soon.

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