用python 3.5安装cPickle

时间:2016-05-10 08:20:38

标签: python docker pickle python-3.5

这可能很傻但我无法使用python 3.5 docker image安装cPickle

Dockerfile

FROM python:3.5-onbuild

requirements.txt

cpickle

当我尝试构建图像时

$ docker build -t sample .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM python:3.5-onbuild
# Executing 3 build triggers...
Step 1 : COPY requirements.txt /usr/src/app/
Step 1 : RUN pip install --no-cache-dir -r requirements.txt
 ---> Running in 016c35a032ee
Collecting cpickle (from -r requirements.txt (line 1))
  Could not find a version that satisfies the requirement cpickle (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for cpickle (from -r requirements.txt (line 1))
You are using pip version 7.1.2, however version 8.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 1

2 个答案:

答案 0 :(得分:72)

cPickle附带标准库...在python 2.x中。你在python 3.x上,所以如果你想要cPickle,你可以这样做:

>>> import _pickle as cPickle

但是,在3.x中,使用pickle更容易。

无需安装任何东西。如果在python 3.x中需要cPickle,那可能就是一个错误。

答案 1 :(得分:3)

在python3.x上,cPickle已从cPickle更改为_pickle。因此,在python3.x中,如果要使用cPickle

,可以执行以下操作

import _pickle