13

I am trying to build a docker container that includes pip.

I am on CentOS 7.

Here is the fragment from running the docker build command:

Step 3 : RUN yum -y install python-pip
 ---> Running in 25d1ba46e6dc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.vcu.edu
 * extras: mirror.clarkson.edu
 * updates: mirrors.unifiedlayer.com
No package python-pip available.
Error: Nothing to do
2015/02/13 19:23:48 The command [/bin/sh -c yum -y install python-pip] returned a non-zero code: 1

I would post my Dockerfile, but it seems that python-pip is not available from the standard CentOS distribution, because this fails too:

sudo yum -y install python-pip
[sudo] password for theuser: 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.thelinuxfix.com
 * extras: mirrors.xmission.com
 * updates: mirrors.tripadvisor.com
No package python-pip available.
Error: Nothing to do

There is this link on solving the install problem for the host system: http://www.liquidweb.com/kb/how-to-install-pip-on-centos-7/ That involves using rpm or curl. I think that is a bit messy for Docker.

Also, if CentOS removed pip from the standard distribution, maybe they have good reason and I should not use brute force to install it.

This does not seem to be an issue in Ubuntu or other distributions. Just CentOS 7.

My concise question is: What is the preferred way to install pip (or an alternative) in CentOS 7?

18

Using this in the Dockerfile allowed me to install pip:

RUN yum -y install epel-release && yum clean all
RUN yum -y install python-pip && yum clean all

That seems much cleaner than using an rpm or curl.

If that still fails, try:

RUN yum -y install --enablerepo="epel" python-pip && yum clean all
| improve this answer | |
  • 1
    I changed it from ; to && so that if command fails it doesnt proceed. – poe123 Sep 22 '16 at 7:33
  • How do you get the latest pip version. RUN yum -y install python-pip but I want to directly install lastest version 10 of pip instead of 8 get installed – Ciasto piekarz May 15 '18 at 9:00

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.