• Home
  • Blog
    • Programming
    • Art
    • Recipes
    • Home Automation
    • Life
    • Friday Faves
    • Books
    • Writing
    • Games
    • Web Accessibility
    • Advent of Code
  • Projects
  • GLSL Shader Art
  • Glitch Art

  • Github
  • Bluesky
  • Mastodon
  • Duolingo
  • LinkedIn
  • RSS
  • Bridgy Fed

mary.codes

Web development, art, and tinkering with fun projects. JavaScript, Python, WebGL, GLSL, Rust, Lua, and whatever else I find interesting at the moment.

Updating a Raspberry Pi to Python 3.9

Mary KnizeBlog iconNov 2nd, 2021
1 min read

Programming

Steps for updating and compiling newer versions of Python on the Raspbian operating system.

I'm starting a project that will involve creating an API in Python, and for that purpose I want to use FastAPI. However, FastAPI requires Python 3.6 or newer, and my Raspberry Pi could only install 3.5 from the package manager. Because of this, I have to install and build Python 3.9.7 manually on my system.

I wanted to install Python 3.10.0, which is the latest, but because it requires OpenSSL 1.1.1 I decided to stick with 3.9. I didn't want to spend the extra time updating other packages.

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev
wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz
tar xf Python-3.9.7.tar.xz
cd Python-3.9.7
./configure --enable-optimizations
make
sudo make altinstall

After I was finished running those commands, I could either symlink Python 3.9 to /usr/bin/python or create an alias in my .bashrc file. I opted for the alias. I also aliased Pip 3.9, which was installed along with Python.

vim ~/.bashrc
alias python='python3.9'
alias pip='pip3.9'

Then, exit vim and source the .bashrc file.

source ~/.bashrc

Now, when I type python --version into my terminal window, I should now see Python 3.9.7.


Other Programming posts

How I'm organizing my work in 2024

Finding the Design Engineer within the Full-Stack Developer

Displaying the current Git branch in my Linux terminal prompt

Generating a 3D map with OpenStreetMap and A-Frame

Translating OpenStreetMap data to HTML5 Canvas with Rust and WebAssembly

Latest posts

I started painting again

100 days of Japanese on Duolingo

How I'm organizing my work in 2024

Watch the documentary 'Good Night Oppy' if you're feeling science-y

Sculpted robo-goldfish, a rainbow office building, and a look inside click farms