由于从https://pypi.python.org/simple/返回的“ Move Permanently”错误,`pip`无法在Docker容器中安装软件包。

时间:2018-12-26 08:57:32

标签: python-2.7 docker pip ubuntu-14.04 pypi

我想在pip Ubuntu 14.04容器中安装docker软件包,但是由于Move Permanentlyhttps://pypi.python.org/simple/返回而总是显示错误。奇怪的是,运行Ubuntu 14.04且主机版本为pythonpip的主机成功安装了pip软件包。

Docker版本:

$ docker --version
Docker version 1.12.6-cs13, build 0ee24d4

Dockerfile:(注意:出于测试目的,我有意输入容器内部)。

FROM ubuntu:14.04
RUN apt-get update
RUN apt-get -qq install python python-pip
WORKDIR /usr/src/app
COPY . .
CMD ["/bin/sh"]

在主机上:

$ 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

内部容器:

# 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

在主机上进行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>

1 个答案:

答案 0 :(得分:4)

这是pip 1.5.4

的已知问题

在使用Dockerfile之前,将以下行添加到pip

RUN python -m pip install --upgrade pip