Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find module cPickle using Python 3.5 and Anaconda

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).

When I try to import cPickle I get "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.

like image 289
Tom Walker Avatar asked Mar 30 '18 18:03

Tom Walker


People also ask

Is cPickle available in Python 3?

There is no cPickle in python 3: A common pattern in Python 2. x is to have one version of a module implemented in pure Python, with an optional accelerated version implemented as a C extension; for example, pickle and cPickle.

What is cPickle python3?

In Python 2, cPickle is the accelerated version of pickle, and a later addition to the standard library. It was perfectly normal to import it with a fallback to pickle. In Python 3 the accelerated version has been integrated and there is simply no reason to use anything other than import pickle .


2 Answers

There is no cPickle in Python 3. Just import pickle. pickle will automatically use the C accelerator.

like image 68
user2357112 supports Monica Avatar answered Sep 20 '22 22:09

user2357112 supports Monica


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

like image 45
Eshaka Avatar answered Sep 21 '22 22:09

Eshaka