我要安装 pip
包裹在 Ubuntu 14.04
中docker
容器,但由于 Move Permanently
总是显示错误从 https://pypi.python.org/simple/
返回.奇怪的(?) pip 是主机运行 Ubuntu 14.04
和 python
的相同版本& pip
安装成功pip
包。
docker 版本:
$ docker --version
Docker version 1.12.6-cs13, build 0ee24d4
Dockerfile: ( Note :为了测试,我故意进入容器内)。
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>
最佳答案
这是 pip 1.5.4
的已知问题
将以下行添加到您的 Dockerfile
使用前 pip
:
RUN python -m pip install --upgrade pip
关于python-2.7 - 由于从 `pip` 返回的 'Move Permanently' 错误,`https://pypi.python.org/simple/` 无法在 Docker 容器内安装软件包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53929705/