CentOS 7 EPEL now includes Python 3.4: yum install python34
However, when I try that, even though Python 3.4 installs successfully, it doesn't appear to install pip. Which is weird, because pip
should be included by default with Python 3.4. which pip3
doesn't find anything, nor does which pip
.
How do I access pip from the Python 3.4 package in CentOS 7 EPEL release?
9 Answers
The easiest way I've found to install pip3 (for python3.x packages) on CentOS 7 is:
This tutorial will show you how to install the latest version of Python 2 and Python 3 on CentOS by compiling from source. The examples below are for Python 2.7.14 and Python 3.6.3, but the procedure is the same for any modern version of Python. Whether you’re running Sopel, or any other Python application, the best way to install Python 3 on CentOS 7 is with Software Collection Libraries. Many guides will tell you to compile it, but that’s much more time consuming, makes you mess with your path, and can’t be kept up to date with yum.
You'll need to have the EPEL repository enabled before hand, of course.
You should now be able to run commands like the following to install packages for python3.x:
Or if you don't have curl
for some reason:
After this you should be able to run
The CentOS 7 yum package for python34 does include the ensurepip
module, but for some reason is missing the setuptools and pip files that should be a part of that module. To fix, download the latest wheels from PyPI into the module's _bundled
directory (/lib64/python3.4/ensurepip/_bundled/
):
then edit __init__.py
to match the downloaded versions:
after which python3.4 -m ensurepip
works as intended. Ensurepip is invoked automatically every time you create a virtual environment, for example:
Hopefully RH will fix the broken Python3.4 yum package so that manual patching isn't needed.
Update: The python34 bug mentioned below has finally been fixed. It is a perfectly fine choice now.
Rather than using broken EPEL python34 packages, you can enable the IUS repo and have it work properly.
- pip inside virtual environments
The main python34u
and python35u
IUS packages include the pyvenv tool (/usr/bin/pyvenv-3.4
or /usr/bin/pyvenv-3.5
) that includes bundled wheels of pip and setuptools for bootstrapping virtual environments.
- global pip
The python34u-pip
and python35u-pip
IUS packages include /usr/bin/pip3.4
and /usr/bin/pip3.5
respectively. These work just fine to install packages to the system site-packages directory.
You will likely need the EPEL repositories installed:
yum install -y epel-release
There is a easy way of doing this by just using easy_install (A Setuptools to package python librarie).
-
Assumption.Before doing this check whether you have python installed into your Centos machine (at least 2.x).
-
Steps to install pip.
-
So lets do install easy_install,
sudo yum install python-setuptools python-setuptools-devel
-
Now lets do pip with easy_install,
sudo easy_install pip
-
That's Great. Now you have pip :)
Figure out what version of python3 you have installed:
and then install the best match. Use reqoquery to find name of resulting pip3.e.g
tells me to use pip3.6 instead of pip3
Below are the steps I followed to install python34 and pip
On CentOS 7, the pip
version is pip3.4
and is located here:
Not the answer you're looking for? Browse other questions tagged pippython-3.4centos7 or ask your own question.
Python is a powerful programming language. It is very friendly and easy to learn. At writing time of this article Python 3.7.3 latest stable version is available to download and install. This tutorial will help you to install Python 3.7.3 on your CentOS, Red Hat & Fedora operating systems.
Step 1 – Requirements
This Python installation required GCC compiler on your system. Login to your server using ssh or shell access. Now, use the following command to install prerequisites for Python before installing it.
- Read: How to Use SSH to Connect Remote Linux Server
Step 2 – Download Python 3.7
Download Python using the following command from the Python official site. You can also download the latest version in place of specified below.
Now extract the downloaded package.
Step 3 – Install Python 3.7
Use below set of commands to compile Python source code on your system using altinstall.
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.
Now remove downloaded source archive file from your system
Step 4 – Check Python Version
Check the latest version installed of python. Use command python3.7 instead of just python.