Keywords: CentOS 7 | Python 3.4 | pip installation
Abstract: This article provides a detailed examination of the complete process for installing the pip package manager for Python 3.4 on CentOS 7 systems. By analyzing the characteristics of the Python 3.4 package in the EPEL repository, it explains why pip is not included by default and presents two reliable solutions. The focus is on the standard installation method using python34-setuptools and easy_install-3.4, while also covering the alternative bootstrap script approach. The content includes environment preparation, command execution, verification steps, and relevant considerations, offering clear operational guidance for system administrators and developers.
Analysis of Python 3.4 and pip Installation Relationship in CentOS 7
When installing Python 3.4 through the EPEL (Extra Packages for Enterprise Linux) repository on CentOS 7 operating systems, users frequently encounter a puzzling phenomenon: although Python 3.4 itself installs successfully, the accompanying pip package manager is not automatically installed. This situation contradicts the expectations of many developers, as pip is typically included as a core component with Python 3.4 in standard Python distributions. This discrepancy stems from the packaging strategy of the EPEL repository, which maintains pip as an optional component rather than a default dependency to adhere to minimal installation principles.
Standard Installation Method via EPEL Repository
To address this issue, the most reliable approach involves utilizing the relevant tool packages available in the EPEL repository. First, ensure the system has the EPEL repository enabled, which can be accomplished by executing sudo yum install epel-release. After installing Python 3.4, two additional key components are required.
The first step is to install the python34-setuptools package, which provides the setuptools framework for Python 3.4:
sudo yum install python34-setuptools
Setuptools is a fundamental tool in the Python ecosystem for building and distributing packages, offering the necessary runtime environment for the easy_install command. Upon installation, the system will include a specially configured easy_install-3.4 executable for Python 3.4.
The second step uses easy_install-3.4 to install pip:
sudo easy_install-3.4 pip
This command downloads and installs the latest version of pip from the Python Package Index (PyPI), configuring it as the dedicated package manager for Python 3.4. The installation process automatically handles dependencies and places the pip3 executable in the system's PATH.
Installation Verification and Basic Usage
After completing the above steps, verify the installation success with the following command:
pip3 --version
This command should display pip's version information along with its associated Python version (3.4.x). If the system indicates the command is not found, it may be necessary to re-login to the terminal or manually update the shell's environment variables. Once verified, you can use pip3 to install third-party packages for Python 3.4:
pip3 install package_name
For example, to install the commonly used requests library, simply execute pip3 install requests. pip will automatically download the package and all its dependencies from PyPI and install them into Python 3.4's site-packages directory.
Alternative Installation Method: Using Bootstrap Script
In addition to the standard method, there exists a more direct alternative approach using the official Python bootstrap script. This method does not rely on specific packages in the EPEL repository but instead fetches the installation script directly from the internet.
One-line installation using curl tool:
curl https://bootstrap.pypa.io/get-pip.py | python3.4
If curl is not installed on the system, use the wget tool for step-by-step execution:
wget https://bootstrap.pypa.io/get-pip.py
python3.4 get-pip.py
Both approaches download the same Python script, which contains the complete pip installation logic. During execution, the script automatically detects the Python environment, downloads necessary components, and completes configuration. Although this method is more concise, it may face limitations in strictly controlled network environments.
Solution Comparison and Selection Recommendations
Comparing the two solutions, the standard method (via python34-setuptools) offers better predictability and stability as it relies entirely on trusted packages from the EPEL repository. This approach is suitable for production environments and scenarios requiring high system consistency. The bootstrap script method, meanwhile, provides greater flexibility, unrestricted by specific repository versions, making it ideal for rapid testing or temporary environments.
Regardless of the chosen method, after installation, verify that the pip3 command functions correctly and consider installing commonly used packages in virtual environments to maintain a clean system Python environment. For users needing to manage multiple Python versions simultaneously, further exploration of tools like pyenv or virtualenv is recommended, as they offer finer version control and environment isolation capabilities.