Operations 6 min read

How to Install Python 3.6.5 on Linux: Step‑by‑Step Guide

This tutorial walks you through checking the pre‑installed Python version, locating its binaries, downloading Python 3.6.5 source, installing required dependencies, compiling and installing the interpreter, creating symlinks, and configuring environment variables on a Linux system.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Install Python 3.6.5 on Linux: Step‑by‑Step Guide

Based on a Linux distribution that ships with Python 2.7.5, you can first verify the existing Python version with python --version. The command shows Python 2.7.5, and you can enter the interactive interpreter with python (exit with Ctrl+D).

The default Python binaries are located at /usr/bin/python and /usr/bin/python2, both of which are symlinks ultimately pointing to /usr/bin/python2.7. Therefore, invoking python, python2, or python2.7 runs the same interpreter.

To install Python 3, download the source package (e.g., Python‑3.6.5.tgz) from https://www.python.org/downloads/source/ and upload it to a directory on the Linux host, such as /root/tools.

Extract the archive with tar -zxvf Python-3.6.5.tgz. Then install the required build dependencies:

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

If you are building Python 3.7 or later, also install libffi-devel. The compilation process typically takes about one minute.

In environments without external network access, you may need to adjust the network configuration. Edit the appropriate interface file (e.g., /etc/sysconfig/network-scripts/ifcfg-ens33) with the correct IP settings, then restart the network service using service network restart before re‑running the yum command.

Proceed with the compilation steps:

./configure --prefix=/root/training/Python-3.6.5
make
make install

The --prefix option sets the installation directory. After a successful build, the setuptools and pip tools are installed alongside Python.

Create a symbolic link for the new interpreter without removing the system Python 2.7.5. Place the link in /usr/local/bin pointing to the newly installed python3 binary.

Finally, configure environment variables to make pip3 easily accessible. Edit ~/.bash_profile and add:

# Configure Python
export PYTHON_HOME=/root/training/Python-3.6.5
export PATH=$PYTHON_HOME/bin:$PATH

Save the file, run source ~/.bash_profile, and verify the configuration with echo $PYTHON_HOME and python3 --version. The installation is now complete, while the original Python 2.7.5 remains functional.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonCompilationLinuxEnvironment VariablesyumSource Build
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.