Questions tagged [pickle]

An object serialization module for Python. Use this tag together with the Python tag for questions related to storing or loading objects with Pickle.

Pickle provides a powerful set of tools for serializing and de-serializing Python objects.

4130 questions
1
vote
1 answer

RecursionError when calling pickeled function

I am trying to run the following code: import pickle def foo(): print("i am foo") pickle_foo = pickle.dumps(foo) def foo(): print("i am the new foo") fkt = pickle.loads(pickle_foo) return fkt() foo() The expected behavior…
Markus
  • 11
  • 1
1
vote
2 answers

How to combine two different trained ML models as one?

I have trained two ml models based on two different datasets. Then I saved them as model1.pkl and model2.pkl . There are two user inputs(not input data for model) like x=0 and x=1 and if x=0 I have to go with model1.pkl for prediction else I have to…
1
vote
0 answers

How to find out what pandas/pickle version I need to unpickle a file?

I have the latest pandas version and am trying to unpickle a file from https://www.cs.toronto.edu/~urtasun/courses/CSC2541_Winter17/project_2.pdf, more specifically from this link…
Kong
  • 1,740
  • 6
  • 19
  • 38
1
vote
0 answers

Is there any way to pickle Selector object in scrapy

I'm trying to implement a caching mechanism in scrapy using my own downloader-middleware. Implementation is as follows class DevCacheMiddleware(object): dev_cache = None def __init__(self, crawler): self.crawler = crawler dcfile =…
SriDatta Yalla
  • 433
  • 5
  • 12
1
vote
1 answer

Attribute lookup Code on builtins failed error happens when a user defined object returned from map operation in Pyspark

I write the following Pyspark code in jupyterLab: class Base: def __init__(self,line): self.line = line def process_line(line): return Base(line) input_path = 'the_path_of_input' samples =…
1
vote
1 answer

Is it safe to pickle and unpickle python objects which contain user input strings?

I have an application with python objects (e.g. class Human). Now I read the name of this human from a file and store it in the human.name attribute. This files content is not trusted. Is it safe to pickle and and unpickle this human instance? I…
PSC
  • 73
  • 6
1
vote
1 answer

Get a function pickleable for using in Differential Evolution workers = -1

#I EDITED MY ORIGINAL POST in order to put a simpler example. I use differential evolution (DE) of Scipy to optimize certain parameters. I would like to use all the PC processors in this task and I try to use the option "workers=-1" The codition…
1
vote
2 answers

Python thread class object and storing via pickle

Within Python, I have been using a thread to execute a pipeline from my main script: thread = PipeLine(input) thread.daemon = True thread.start() result = thread.join() My class object in the other script looks this: class…
Tijmen W
  • 11
  • 1
1
vote
0 answers

Bokeh Live Plot Error - pickle data - unpack requires a string argument of length 8

Function: I try to build a skript which shows geo-data on a map. This data changes and should be updatet continually. I have a file which gathers the neccesary information via ROS and saves it in a dict which will be serialized it with pickle. This…
Pm740
  • 81
  • 7
1
vote
0 answers

Save Variable to Disk from outside

I've made a script that saves cache to disk and loads it everytime the file is executed. -bar.py: from cachetools import cached import pickle try: with open('mycache.pickle', 'rb') as f: cache = pickle.load(f) except…
Stack
  • 803
  • 5
  • 16
1
vote
2 answers

How does multiprocessing code pickle the map function?

I am writing a grid searching utility and am trying to use multiprocessing to speed up calculation. I have an objective function which interacts with a large class which I cannot pickle due to memory constraints (I can only pickle relevant…
Raven
  • 466
  • 1
  • 5
  • 16
1
vote
1 answer

TypeError: an integer is required (got type bytes) while loading the pickle file

It throws below error while loading the pickle file. return types.CodeType( TypeError: an integer is required (got type bytes) if __model is None: with open('banglore_home_prices_model_2.pickle', 'rb') as f: __model = pickle.load(f) - >…
1
vote
1 answer

_gdbm.error: Database needs recovery -- after running out of storage while fetching api data

I really don't know how to help myself, being unfamiliar with this kind of error, and not finding anything on the Google landscape really. My last hope is one of you guys since I don't know where else to go with this. I tried reinstalling all…
1
vote
0 answers

Cassandra Reaper JMX_AUTH error, when using cassandra as backend storage?

For the reaper-2.0.5 and cassandra-3.11.8 integration have made below changes:- In the cassandra-env.sh file have changed the value of variable LOCAL_JMX=no in line number-249. In line number-267 have changed the value for jmxremote.autheticate…
andy
  • 413
  • 1
  • 6
  • 16
1
vote
1 answer

Problem with Cython, module import, and Pickling

I use a custom random number generator build with Cython. I don't understand why, but it no longer works... I guess it is related to Python 2.7, or maybe a new version of Cython. In dcmtrand.pyx, I have: ... import dcmt ... cdef class RandomState: …
Charles Brunet
  • 18,389
  • 21
  • 77
  • 120