Centos – /bin/python3: No module named pip

centospackage-managementpython

I installed Python 3.4 on CentOS 7.3:

sudo yum install epel-release
sudo yum install python34.x86_64

There was python 2 installed before under

type python
python is hashed (/bin/python)

So version 3 is under python3:

type python3
python3 is hashed (/bin/python3)

On Windows, I have version 3.5 and the way I install packages is:

python -m pip install <package_name>

So I tried the same on CentOS but calling python3 instead of python:

python3 -m pip install psycopg2
/bin/python3: No module named pip

How do I install or enable pip in Python 3.4 on CentOS so that I can install packages?

Best Answer

Enable epl-repo:

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
rpm -ivh epel-release-7-9.noarch.rpm

Install pip:

sudo yum --enablerepo=epel install python-pip
pip install -U pip

Enable Software Collections:

sudo yum install centos-release-scl
sudo yum install scl-utils-build
sudo yum-config-manager --enable rhel-server-rhscl-7-rpms

Install the rh-python34 collection.

sudo yum install rh-python34
scl enable rh-python34 bash

Install PostgreSQL development header files and libraries:

sudo yum install postgresql-devel

Install Python development header files and libraries:

sudo yum install python-devel

Install your package:

python3 -m pip install psycopg2
Related Question