使用 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
Can't find module cPickle using Python 3.5 and Anaconda
提问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 cPickle
in Python 3. Just import pickle
. pickle
will automatically use the C accelerator.
cPickle
Python 3 中没有。只需 import pickle
。pickle
将自动使用 C 加速器。
回答by Eshaka
try import pickle as cPickle
. this way you don't have to edit much
试试import pickle as cPickle
。这样你就不必编辑太多