How to Resolve 'No Package python-dev Available' Error When Installing on CentOS 6.5 (No GUI Solutions)
Introduction
If you’ve encountered the error No package python-dev available while trying to install Python development files on CentOS 6.5, you’re not alone. This issue is common, especially on older Linux distributions like CentOS 6.5, which reached its end-of-life (EOL) on November 30, 2020. The error typically arises due to misnamed packages, outdated repository configurations, or discontinued support for legacy systems.
This guide will walk you through step-by-step, command-line-only solutions to resolve this error. We’ll cover verifying package names, updating repositories, installing dependencies, and even compiling from source (if necessary). By the end, you’ll have the Python development tools required for tasks like compiling Python modules or building applications.
Table of Contents
- Understanding the "No Package python-dev Available" Error
- Prerequisites
- Step-by-Step Solutions
- Step 1: Confirm the Correct Package Name
- Step 2: Update CentOS 6.5 Repositories (Critical for EOL Systems)
- Step 3: Clear Yum Cache and Refresh Metadata
- Step 4: Install python-devel
- Step 5: Alternative: Install Python Development Files from Source (If Repositories Fail)
- Verifying the Installation
- Troubleshooting Common Issues
- Conclusion
- References
1. Understanding the "No Package python-dev Available" Error
The error No package python-dev available occurs when the package manager (yum, in CentOS) cannot find a package named python-dev in its configured repositories. Here’s why this happens:
- Package Name Mismatch: On Debian/Ubuntu systems, Python development files are packaged as
python-dev. However, CentOS/RHEL systems usepython-devel(note the-develsuffix instead of-dev). Usingpython-devon CentOS is incorrect. - Outdated Repositories: CentOS 6.5 is EOL, so its default repositories (e.g.,
base,updates) are no longer maintained. The original mirror URLs (e.g.,mirror.centos.org) now redirect to empty pages, causingyumto fail finding packages.
2. Prerequisites
Before proceeding, ensure you have:
- A CentOS 6.5 system with command-line access (no GUI required).
- root or sudo privileges (to modify system files and install packages).
- An active internet connection.
3. Step-by-Step Solutions
Step 1: Confirm the Correct Package Name
First, verify that you’re using the correct package name for CentOS. Run this command to search for Python development packages:
yum search python-devel
Expected Output: You should see results like python-devel.x86_64 : The libraries and header files needed for Python development.
If no results appear, proceed to the next step to fix your repositories.
Step 2: Update CentOS 6.5 Repositories (Critical for EOL Systems)
CentOS 6.5’s default repositories are no longer hosted on mirror.centos.org. To resolve this, update your repository files to point to the CentOS Vault, which archives old releases.
Step 2.1: Backup Existing Repo Files
Before editing, back up your current repository configuration:
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
Step 2.2: Edit the CentOS-Base.repo File
Open the main repository file with a text editor like vi or nano:
sudo vi /etc/yum.repos.d/CentOS-Base.repo
Replace the entire content with the following (this points to the CentOS 6 Vault):
SSL/TLS Note:
vault.centos.orgnow redirects HTTP to HTTPS. Older CentOS 6 systems may have TLS libraries too old to connect. If you encounter SSL errors, addsslverify=0to each repository section, or use an alternative mirror such ashttp://linuxsoft.cern.ch/centos-vault/6.5/orhttp://archive.kernel.org/centos-vault/6.5/in place ofhttp://vault.centos.org/6.5/.
[base]
name=CentOS-6 - Base
baseurl=http://vault.centos.org/6.5/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
sslverify=0
[updates]
name=CentOS-6 - Updates
baseurl=http://vault.centos.org/6.5/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
sslverify=0
[extras]
name=CentOS-6 - Extras
baseurl=http://vault.centos.org/6.5/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
sslverify=0
[centosplus]
name=CentOS-6 - Plus
baseurl=http://vault.centos.org/6.5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
sslverify=0
[contrib]
name=CentOS-6 - Contrib
baseurl=http://vault.centos.org/6.5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
sslverify=0
Save and exit: In vi, press Esc, type :wq, and hit Enter.
Step 3: Clear Yum Cache and Refresh Metadata
After updating repositories, clear the old yum cache and rebuild it with the new repository data:
sudo yum clean all # Clear cached package data
sudo yum makecache # Rebuild the cache with new repo info
Step 4: Install python-devel
Now try installing the Python development package again with the corrected repository configuration:
sudo yum install python-devel -y
If Successful: You’ll see output like Installed: python-devel.x86_64 0:2.6.6-64.el6. Skip to Verifying the Installation.
If Still Failing: Proceed to install from source (Step 5).
Step 5: Alternative: Install Python Development Files from Source (If Repositories Fail)
If the repository method fails (e.g., due to missing dependencies), compile Python from source to get the development files.
Step 5.1: Install Build Dependencies
First, install tools required to compile Python:
sudo yum install gcc make openssl-devel zlib-devel -y
Step 5.2: Download Python Source Code
CentOS 6.5 ships with Python 2.6 by default. Download the matching source code from the Python 2.6.6 Release Page:
wget https://www.python.org/ftp/python/2.6.6/Python-2.6.6.tgz
Security Note: Python 2.6.6 reached end-of-life on October 29, 2013 and no longer receives security updates. If possible, consider installing a newer Python version (e.g., 2.7 or 3.x) alongside the system Python using the same source-compile method described here.
Step 5.3: Extract and Compile
Extract the tarball and compile Python:
tar -xzf Python-2.6.6.tgz
cd Python-2.6.6
./configure --prefix=/usr/local/python2.6 # Install to a custom directory to avoid overwriting system Python
make
sudo make install
Step 5.4: Verify Development Files
The source install includes header files (e.g., Python.h) in /usr/local/python2.6/include/python2.6/. Confirm they exist:
ls /usr/local/python2.6/include/python2.6/Python.h
Expected Output: The path to Python.h (no error means success).
4. Verifying the Installation
To confirm python-devel is installed (via repo or source):
For Repository Installs:
rpm -q python-devel # Check if the package is installed
Expected Output: python-devel-2.6.6-64.el6.x86_64 (version may vary).
For Source Installs:
Check for the presence of header files:
ls /usr/include/python2.6/Python.h # Repo install path
# OR
ls /usr/local/python2.6/include/python2.6/Python.h # Source install path
5. Troubleshooting Common Issues
Issue 1: GPG Key Errors
If you see GPG key retrieval failed: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404", import the CentOS 6 GPG key manually:
sudo rpm --import http://vault.centos.org/6.5/os/x86_64/RPM-GPG-KEY-CentOS-6
If the above fails due to SSL issues, try an alternative mirror:
sudo rpm --import http://linuxsoft.cern.ch/centos-vault/6.5/os/x86_64/RPM-GPG-KEY-CentOS-6
Issue 2: Repositories Still Not Working
Double-check your CentOS-Base.repo file. Ensure baseurl points to http://vault.centos.org/6.5/os/$basearch/ (replace 6.5 with your CentOS version if needed). If you experience SSL/TLS connection errors, add sslverify=0 to each repository section or switch to an alternative mirror such as http://linuxsoft.cern.ch/centos-vault/6.5/ or http://archive.kernel.org/centos-vault/6.5/.
Issue 3: Missing Dependencies
If yum install python-devel fails with Error: Package: python-devel..., install missing dependencies with:
sudo yum install -y $(yum deplist python-devel | grep provider | awk '{print $2}' | sort -u)
6. Conclusion
The No package python-dev available error in CentOS 6.5 is typically caused by using the wrong package name (python-dev instead of python-devel) or outdated repositories. By updating your repositories to the CentOS Vault and installing python-devel, you can resolve this issue. If all else fails, compiling Python from source ensures you get the necessary development files.
Note: CentOS 6 reached end-of-life on November 30, 2020 and is no longer supported. CentOS 7 (EOL June 30, 2024) and CentOS 8 (EOL December 31, 2021) are also end-of-life. For production systems, migrate to a supported distribution such as Rocky Linux or AlmaLinux to receive ongoing security updates.
7. References
- CentOS Vault – Archives of old CentOS releases.
- Python 2.6.6 Release Page
- CentOS 6 EOL Announcement
- CentOS Community Newsletter – December 2020
- Yum Repository Configuration
- Fixing Yum Repos on CentOS 6 After EOL – Additional mirror options and troubleshooting.
- CentOS End-of-Life Timeline