{"id":5196,"date":"2019-11-22T09:31:44","date_gmt":"2019-11-22T04:01:44","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=5196"},"modified":"2026-11-02T18:21:34","modified_gmt":"2026-11-02T12:51:34","slug":"how-to-install-python-from-source-code","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-install-python-from-source-code\/","title":{"rendered":"Install Python from Source: 7 Easy Steps for Linux"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date:<\/strong> November 22, 2019<br><strong>Last Updated:<\/strong> November 02, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Installing Python from source code on Linux gives administrators and developers greater control over the Python version, installation directory, and build configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The default Python version available through a Linux package manager may not always meet your application requirements. In such situations, you can download the Python source code, compile it, and install the required version independently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we will explain how to <strong>install Python from source<\/strong> on Linux, including the required dependencies, compilation commands, custom installation paths, and verification steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We will also explain how to install multiple Python versions without affecting the system&#8217;s default Python installation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting the Python source installation, ensure that you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Linux server with Ubuntu, Debian, CentOS, RHEL, or a compatible distribution.<\/li>\n\n\n\n<li>Root or sudo privileges.<\/li>\n\n\n\n<li>An active internet connection.<\/li>\n\n\n\n<li>Sufficient disk space for downloading and compiling the source code.<\/li>\n\n\n\n<li>A C compiler and the required development libraries.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The commands in this tutorial use a version placeholder. Replace <code>X.Y.Z<\/code> with the exact Python release version you intend to install. Always choose a currently supported Python release from the official Python website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Official download page: <a href=\"https:\/\/www.python.org\/downloads\/source\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.python.org\/downloads\/source\/<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/Installing-Python-from-Source-on-Linux-1.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"828\" height=\"941\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/Installing-Python-from-Source-on-Linux-1.png\" alt=\"\" class=\"wp-image-12725\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/Installing-Python-from-Source-on-Linux-1.png 828w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/Installing-Python-from-Source-on-Linux-1-264x300.png 264w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/Installing-Python-from-Source-on-Linux-1-768x873.png 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">2. Install Python Build Dependencies<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before compiling Python, we need to install the required development tools and libraries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These dependencies allow Python to build optional standard library modules such as SSL, SQLite, compression, and database-related modules.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">For Ubuntu\/Debian<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Execute the following commands:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update\n\nsudo apt install -y \\\nbuild-essential wget curl \\\nlibssl-dev zlib1g-dev libbz2-dev \\\nlibreadline-dev libsqlite3-dev \\\nlibffi-dev liblzma-dev \\\nlibncurses-dev tk-dev uuid-dev \\\nlibgdbm-dev pkg-config<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">For CentOS\/RHEL\/Fedora<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For distributions using DNF, execute:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf install -y \\\ngcc gcc-c++ make wget curl \\\nopenssl-devel zlib-devel bzip2-devel \\\nreadline-devel sqlite-devel \\\nlibffi-devel xz-devel \\\nncurses-devel tk-devel \\\ngdbm-devel libuuid-devel \\\npkgconf-pkg-config<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Package names may vary depending on the Linux distribution and release.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Download Python Source Code<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the required dependencies are installed, download the Python source archive.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Visit the official Python source archive:<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/www.python.org\/ftp\/python\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Select the required release directory and download its <code>.tgz<\/code> source archive.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, replace <code>X.Y.Z<\/code> with your selected Python version:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">PYTHON_VERSION=X.Y.Z\n\nwget https:\/\/www.python.org\/ftp\/python\/${PYTHON_VERSION}\/Python-${PYTHON_VERSION}.tgz<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also verify that the downloaded archive exists:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls -lh Python-${PYTHON_VERSION}.tgz<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For production environments, verify the archive&#8217;s checksum against the official Python release information before extracting it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Extract the Python Source Archive<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After downloading the source archive, extract it using the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tar -xzf Python-${PYTHON_VERSION}.tgz<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to the extracted directory:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd Python-${PYTHON_VERSION}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should now be inside the Python source directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the extracted files:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls -l<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You will find the configuration script, Makefile-related source files, and other files required for compiling Python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Configure the Python Installation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The next step is to configure the Python source code before compilation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Execute:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.\/configure<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration script checks the system environment, compiler, and available libraries required to build Python.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It also generates the Makefile, which contains the instructions needed for the compilation process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Optional performance optimization:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a performance-optimized build, you can use:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.\/configure --enable-optimizations<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This enables Profile Guided Optimization (PGO). It can improve runtime performance but increases the compilation time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a custom installation directory, you can use the <code>--prefix<\/code> option, which we will explain later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Compile and Test Python<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once configuration is completed successfully, compile the Python source code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Execute:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">make -j \"$(nproc)\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>make<\/code> command starts the compilation process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>-j<\/code> option allows multiple compilation jobs to run simultaneously. The <code>nproc<\/code> command identifies the number of available processing units.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After compilation, run the test suite:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">make test<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command executes Python&#8217;s test suite to check whether the compiled interpreter and its supported modules are working correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Testing may take some time depending on the server&#8217;s CPU and available resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the tests report failures, review the output and resolve any missing dependencies or build-related issues before proceeding.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. Install Python on Linux<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After successful compilation and testing, install Python.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We recommend using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo make altinstall<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>altinstall<\/code> target installs the version-specific Python executable without creating or replacing the generic <code>python3<\/code> executable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, a Python 3.x installation may create:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/usr\/local\/bin\/python3.x<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why use make altinstall instead of make install?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using <code>make install<\/code> can overwrite or interfere with the existing <code>python3<\/code> executable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The official Python documentation recommends <code>make altinstall<\/code> when installing another Python version alongside an existing installation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is particularly important on production Linux servers where system utilities may depend on the distribution-provided Python interpreter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8. Install Python in a Custom Directory<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose your server already has a Python version installed, but you need another version for a specific application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this situation, installing the new version in a separate directory is a better approach.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, assume you want to install Python under:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to the extracted Python source directory and execute:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.\/configure --prefix=\/opt\/python\/X.Y.Z<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This tells the configuration script to use the specified directory as the installation prefix.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, compile Python:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">make -j \"$(nproc)\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Run the test suite:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">make test<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, install Python:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo make altinstall<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After installation, the Python executable will be available at a version-specific location similar to:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z\/bin\/python3.x<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can execute this Python version directly without changing the system&#8217;s default Python executable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z\/bin\/python3.x --version<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This approach is useful when maintaining multiple Python versions for different applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. Verify the Python Installation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After completing the installation, verify that Python is working correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a default <code>\/usr\/local<\/code> installation:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/usr\/local\/bin\/python3.x --version<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a custom installation:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z\/bin\/python3.x --version<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the installation path:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z\/bin\/python3.x -c \"import sys; print(sys.executable)\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also check whether pip is available:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z\/bin\/python3.x -m pip --version<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If pip is not available and the Python build includes <code>ensurepip<\/code>, initialize it using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z\/bin\/python3.x -m ensurepip --upgrade<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can now create a virtual environment for your application:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z\/bin\/python3.x -m venv \/opt\/myapp\/venv<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Activate it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">source \/opt\/myapp\/venv\/bin\/activate<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your application can now use this Python environment independently of the system Python installation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Installing Python from source code provides flexibility in choosing the required Python version, configuring build options, and selecting a custom installation directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By using <code>make altinstall<\/code> and a separate installation prefix, you can maintain multiple Python versions without unnecessarily modifying the system&#8217;s default Python interpreter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For production servers, always use a supported Python release, install the necessary development dependencies, and test the compiled installation before deploying applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Why should I install Python from source code?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Installing Python from source allows you to select a specific release, configure compilation options, and customize the installation directory instead of relying entirely on the version provided by your Linux distribution.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. What is the difference between make install and make altinstall?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>make install<\/code> installs Python with the generic <code>python3<\/code> executable, which can interfere with an existing installation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>make altinstall<\/code> installs the version-specific executable and is recommended when maintaining multiple Python versions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Can I install multiple Python versions on the same Linux server?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. You can install different Python versions in separate directories using the <code>--prefix<\/code> configuration option. This allows each version to operate independently.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Where does Python get installed by default?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When no custom prefix is specified, the default installation prefix for a typical Unix source build is <code>\/usr\/local<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. How do I check the installed Python version?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Execute:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">python3.x --version<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively, specify the complete executable path:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/python\/X.Y.Z\/bin\/python3.x --version<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-install-python3-and-pip3-in-ubuntu-16-04\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to install python3 and pip3 in Ubuntu 16.04<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-python-pip-boto-windows-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Install Python, pip, and Boto on Windows Server<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to Our Technology Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Need assistance installing Python from source, managing multiple Python versions, or configuring Python applications on Linux servers? Our team can help with Python installation, server configuration, application deployment, and ongoing Linux server management.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/contact?utm_source=chatgpt.com\">Connect with our technology experts.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: November 22, 2019Last Updated: November 02, 2026 Introduction Installing Python from source code on Linux gives administrators and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":12727,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[734],"class_list":["post-5196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-architecture","tag-install-python-from-source-code","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1lO","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/11\/Installing-Python-from-Source-on-Linux.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=5196"}],"version-history":[{"count":2,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5196\/revisions"}],"predecessor-version":[{"id":12728,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5196\/revisions\/12728"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/12727"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}