4

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?

  • 1
    try yum install python34-pip – jordanm Feb 17 '17 at 17:01
3

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
  • after running the first two commands, i still didn't have yum-config-manager: bash: yum-config-manager: command not found – amphibient Feb 17 '17 at 18:45
  • run yum install -y yum-utils – GAD3R Feb 17 '17 at 18:46
  • i did try python3 -m pip install psycopg2 but git an error. any chance we can go to chat so i show you the lengthy trace ? – amphibient Feb 17 '17 at 18:49
  • 1
    or i can ask another question – amphibient Feb 17 '17 at 18:50
  • 1
    this is what fixed it: sudo yum install postgresql-devel – amphibient Feb 17 '17 at 19:10
3

Download this installer script:

wget https://bootstrap.pypa.io/get-pip.py

Run it as root (or sudo it)

python3 get-pip.py

  • 1
    This worked for me! – Aaron Dec 20 '17 at 22:20
2

For CentOS 7 you would need to run this:

sudo yum install python34-setuptools
sudo easy_install-3.4 pip

Edit: You should then be able to install using pip3 install <package>

  • after installing the setup tools, bash: easy_install: command not found – amphibient Feb 17 '17 at 18:09
  • I'm sorry try this sudo easy_install-3.4 pip – Pythonic Feb 17 '17 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.