本文介绍了使用 python 3.5 安装 cPickle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能很愚蠢,但我无法使用 python 3.5 docker 映像安装 cPickle

Dockerfile

FROM python:3.5-onbuild

requirements.txt

cpickle

当我尝试构建图像时

$ docker build -t 示例.将构建上下文发送到 Docker 守护进程 3.072 kB第 1 步:从 python:3.5-onbuild# 执行 3 个构建触发器...第 1 步:复制 requirements.txt/usr/src/app/第 1 步:运行 pip install --no-cache-dir -r requirements.txt--->运行在 016c35a032ee收集 cpickle(来自 -r requirements.txt(第 1 行))找不到满足 cpickle 要求的版本(来自 -r requirements.txt(第 1 行))(来自版本:)找不到 cpickle 的匹配分布(来自 -r requirements.txt(第 1 行))您使用的是 pip 版本 7.1.2,但版本 8.1.1 可用.您应该考虑通过pip install --upgrade pip"命令进行升级.命令/bin/sh -c pip install --no-cache-dir -r requirements.txt"返回非零代码:1
解决方案

cPickle 带有标准库……在 python 2.x 中.你使用的是 python 3.x,所以如果你想要 cPickle,你可以这样做:

>>>将 _pickle 导入为 cPickle

然而,在 3.x 中,使用 pickle 更容易.

无需安装任何东西.如果某些东西需要在 python 3.x 中使用 cPickle,那么这可能是一个错误.

This might be silly but I am unable to install cPickle with python 3.5 docker image

Dockerfile

FROM python:3.5-onbuild

requirements.txt

cpickle

When I try to build the image

$ 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
解决方案

cPickle comes with the standard library… in python 2.x. You are on python 3.x, so if you want cPickle, you can do this:

>>> import _pickle as cPickle

However, in 3.x, it's easier just to use pickle.

No need to install anything. If something requires cPickle in python 3.x, then that's probably a bug.

这篇关于使用 python 3.5 安装 cPickle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-05 09:29