使用python 3.5安装cPickle
这可能很愚蠢,但我无法使用python 3.5 docker映像安装使用python 3.5安装cPickle,python,docker,pickle,python-3.5,Python,Docker,Pickle,Python 3.5,这可能很愚蠢,但我无法使用python 3.5 docker映像安装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
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
cPickle
附带了python 2.x中的标准库。您使用的是Python3.x,因此如果需要cPickle
,可以执行以下操作:
>>> import _pickle as cPickle
然而,在3.x中,只需使用pickle
就更容易了
不需要安装任何东西。如果Python3.x中需要
cPickle
,那么这可能是一个bug。ahh!python3.x中的\u pickle
是不是取代了cPickle
?或者pickle
也会一样快?是的,pickle
使用\u pickle
,所以它也很快,可以处理子类。我正在使用Python 3.6.6,并尝试了所有方法:导入pickle作为cPickle,导入pickle,导入_pickle作为cPickle,但仍然有错误“ModuleNotFoundError:没有名为'cPickle'的模块”@帕里:我不认为你在上面的评论中详述的三个进口声明会产生具体的错误。也许您应该进一步研究,如果确实遇到了一些新问题或错误,可能会问一个新的SO问题。在Python2中,cPickle是pickle的加速版本,是后来添加到标准库中的。这是完全正常的进口它与一个后备的泡菜。在Python3中,加速版已经被集成,除了import pickle
之外,没有任何理由使用任何东西。