使用 Python 3.5 和 Anaconda 找不到模块 cPickle

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49579282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:09:09  来源:igfitidea点击:

Can't find module cPickle using Python 3.5 and Anaconda

pythonanacondapickleversioning

提问by Tom Walker

I am trying to use cPickle on a windows box, using Anaconda. I am using python 3.5. I am not using a virtualenv (though probably should be).

我正在尝试使用 Anaconda 在 Windows 框上使用 cPickle。我正在使用 python 3.5。我没有使用 virtualenv(虽然可能应该是)。

When I try to import cPickle I get "ImportError: No module named 'cPickle'"

当我尝试导入 cPickle 时,出现“ImportError: No module named 'cPickle'”

Python 3.5.0 |Anaconda custom (64-bit)| (default, Dec  1 2015, 11:46:22) [MSC v.
1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'cPickle'

My understanding is that cPickle comes built in with Python 3.5, so I can't understand why cPickle is not found. Any idea what has gone wrong/how I can clean things up/how to troubleshoot the issue.

我的理解是 cPickle 内置于 Python 3.5 中,所以我不明白为什么找不到 cPickle。知道出了什么问题/我如何清理东西/如何解决问题。

回答by user2357112 supports Monica

There is no cPicklein Python 3. Just import pickle. picklewill automatically use the C accelerator.

cPicklePython 3 中没有。只需 import picklepickle将自动使用 C 加速器。

回答by Eshaka

try import pickle as cPickle. this way you don't have to edit much

试试import pickle as cPickle。这样你就不必编辑太多