I would like to install pip
packages inside a Ubuntu 14.04
docker
container but it always shows errors due to Move Permanently
returned from https://pypi.python.org/simple/
. The weird (?) point is that the host running Ubuntu 14.04
and the same versions of python
& pip
was successful to install pip
packages.
Docker version:
$ docker --version
Docker version 1.12.6-cs13, build 0ee24d4
Dockerfile: (Note: For testing I intentionally enter inside the container).
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get -qq install python python-pip
WORKDIR /usr/src/app
COPY . .
CMD ["/bin/sh"]
On host:
$ uname -a
Linux duong2179-ubuntu 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 2.7.6
$ pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
$ sudo pip install simplejson==3.3.1
Downloading/unpacking simplejson==3.3.1
...
Successfully installed simplejson
Inside container:
# uname -a
Linux duong2179-ubuntu 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
# python --version
Python 2.7.6
# pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
# pip install simplejson==3.3.1
Downloading/unpacking simplejson==3.3.1
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement simplejson==3.3.1
From host do curl
-ing https://pypi.python.org/simple/
:
$ curl https://pypi.python.org/simple/
<html><head><title>301 Moved Permanently</title></head><body><center><h1>301 Moved Permanently</h1></center></body></html>
This is a known problem of pip 1.5.4
Add following line to your Dockerfile
before using pip
:
RUN python -m pip install --upgrade pip