🧩 Introduction
While Kali Linux often ships with the latest version of Python pre-installed, certain tools and projects may require compatibility with older versions. In this quick guide, we’ll walk through the process of installing Python 3.10.12 alongside the system’s existing Python (e.g., Python 3.13.5), without causing conflicts. By building Python from source and installing it into a custom directory, you maintain full control over version usage—ideal for virtual environments, scripting needs, or legacy tool support.
✅ Step-by-Step Guide to Install Python 3.10.12 on Kali Linux
1. Install Build Dependencies
sudo apt update sudo apt install -y build-essential libssl-dev zlib1g-dev \ libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev \ libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev \ tk-dev uuid-dev libffi-dev wget
2. Download Python 3.10.12 Source
cd /usr/src sudo wget https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz sudo tar xvf Python-3.10.12.tgz cd Python-3.10.12
3. Compile Python
sudo ./configure --enable-optimizations --prefix=/opt/python-3.10 sudo make -j$(nproc) sudo make altinstall
Note: make altinstall
prevents overwriting /usr/bin/python
.
4. Verify Installation
/opt/python-3.10/bin/python3.10 --version
5. (Optional) Create a Symlink
sudo ln -s /opt/python-3.10/bin/python3.10 /usr/local/bin/python3.10
6. (Optional) Create Virtual Environments with Python 3.10
sudo apt install python3-venv # Install Python3 virtual environment /opt/python-3.10/bin/python3.10 -m venv ~/venvs/py310 source ~/venvs/py310/bin/activate # Activate Virtual Environment deactivate # Exit Virtual Environment
🏁 Final Thoughts
Installing Python 3.10.12 alongside newer versions on Kali Linux is both safe and practical when done with care. This method ensures your system remains stable while giving you the flexibility to run older Python-based applications or create isolated environments. Whether you’re testing legacy code, using a specific library version, or learning Python version management, having multiple Python versions at your disposal can significantly improve your development workflow.