How to install Python 3.8 along with Python 3.9 in Arch Linux?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Arch Linux ships the latest Python version in its official repositories, but many projects require older versions like Python 3.8 alongside the system Python. The recommended approach is to use pyenv, which compiles and manages multiple Python versions in your home directory without affecting system packages. Alternatives include installing from the AUR (Arch User Repository) or building from source. Each method has trade-offs in convenience, maintenance, and system integration.
Method 1: pyenv (Recommended)
pyenv compiles Python from source in ~/.pyenv/versions/. It does not touch the system Python and allows switching between versions per project or globally.
Setting Active Python Versions
pyenv local creates a .python-version file that automatically activates when you cd into the directory. pyenv global sets the default for your user. pyenv shell overrides for the current terminal session.
Method 2: AUR Package
AUR packages install Python system-wide alongside the official Python. The binary is accessible as python3.8, keeping python3 pointing to the system version.
Method 3: Build from Source
make altinstall is critical — it installs as python3.8 and pip3.8 without creating python3 or pip3 symlinks that would overwrite the system Python.
Creating Virtual Environments
Virtual environments isolate project dependencies regardless of which Python installation method you use. Always use virtual environments for project development.
Using pyenv with pyenv-virtualenv
pyenv-virtualenv combines Python version management with virtual environments, giving you named environments tied to specific Python versions.
Common Pitfalls
- Using make install instead of make altinstall:
make installoverwrites the systempython3symlink, breaking system tools that depend on the Arch-provided Python. Always usemake altinstallwhen building from source. - Missing build dependencies: Python's
configurescript silently skips optional modules (like_ssl,_sqlite3,_lzma) if their development headers are missing. Installopenssl,zlib,xz,tk, andsqlitebefore building. - AUR packages breaking on system updates: When Arch updates its system Python or shared libraries, AUR Python packages may need rebuilding. Run
yay -S python38again after major system updates if the binary stops working. - pyenv not updating PATH correctly: If
python --versionstill shows the system Python afterpyenv global, ensureeval "$(pyenv init -)"is in your shell config and the shell was restarted. pyenv works by prepending shims to your PATH. - Conflicting pip installations: Running
pip installwithout a virtual environment installs packages into the active Python's site-packages. This can cause version conflicts between Python 3.8 and 3.9. Always work inside virtual environments.
Summary
- Use
pyenvfor the cleanest multi-version Python setup on Arch Linux - Use AUR packages (
yay -S python38) for system-wide installation without building from source - Use
make altinstall(notmake install) when building from source to avoid overwriting system Python - Always create virtual environments for project isolation regardless of installation method
pyenv localcreates per-directory Python version switching via.python-versionfiles- Install all build dependencies before compiling Python to avoid missing modules
Related reading
- How to install python modules without root access?
- How to install Python MySQLdb module using pip?
- How to install Python MySQLdb module using pip?
- How to install Python package from GitHub?
- How to install tensorflow2.3.0
- How to install tensorflow 2.0 on Mac or Linux?
- How to Install tensorflow addons via conda
- how to install tensorflow for windows 7 32bit system?i installed python 3.532 bit into my system and also installed anaconda 3.4.432 bit
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.