docker 使用python 3.5安装cPickle

aelbi1ox  于 2023-02-18  发布在  Docker
关注(0)|答案(3)|浏览(266)

这可能是愚蠢的,但我无法安装cPickle与python3.5docker图像

停靠文件

FROM python:3.5-onbuild

要求.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
cu6pst1q

cu6pst1q1#

cPickle在python 2.x中附带了标准库......您使用的是python 3.x,因此如果您需要cPickle,可以执行以下操作:

>>> import _pickle as cPickle

然而,在Python 3.x中,使用pickle会更容易。
不需要安装任何东西,如果在python3.x中需要cPickle,那么这可能是一个bug。

w1e3prcc

w1e3prcc2#

您可以在python2和python3中使用此方法

try:
  import cPickle as pickle
except:
  import pickle
bxjv4tth

bxjv4tth3#

我正在使用python 3.10.9,并尝试运行python 2编写的脚本,所以在阅读了上面的评论后,这个命令可以工作。import pickle as pkl

相关问题