pickle

ValueError : not enough values to unpack. why?

筅森魡賤 提交于 2019-12-12 05:31:41
问题 I am learning file management from a website and I tried executing a certain script but it hasn't worked out well for me. It keeps returning this error at the line : city, day, time = line.split() ValueError: not enough values to unpack (expected at least 2, got 0) I am trying to alphabetize and pickle dump a list of cities and their time zones, the text file has several lines such as this: Salt lake city Sun 09:52 San Francisco Sun 00:52 Amsterdam Sun 08:52 Denver Sun 01:52 San Salvador Sun

in a pickle: how to serialise legacy objects for submission to a Python multiprocessing pool

梦想与她 提交于 2019-12-12 04:40:01
问题 I have written a nice parallel job processor that accepts jobs (functions, their arguments, timeout information etc.) and submits then to a Python multiprocessing pool. I can provide the full (long) code if requested, but the key step (as I see it) is the asynchronous application to the pool: job.resultGetter = self.pool.apply_async( func = job.workFunction, kwds = job.workFunctionKeywordArguments ) I am trying to use this parallel job processor with a large body of legacy code and, perhaps

Pythons multiprocess module (with dill) gives an unhelpful AssertionError

本秂侑毒 提交于 2019-12-12 03:25:55
问题 I have installed dill/pathos and its dependencies (with some difficulty) and I'm trying to perform a function over several processes. The class/attribute Model(self.xml,self.exp_data,i).SSR is custom made and depends on loads of other custom functions so I apologize in advance for not being able to provide 'runnable' code. In brief however, it takes some experimental data, integrates a system of ODE's with python's pysces module and calculates the sum of squares ( SSR ). The purpose for

Python multiprocessing error with class methods

梦想的初衷 提交于 2019-12-12 02:46:57
问题 I am writing a program where I have object oriented code where I am trying to do multiprocessing. I was getting pickle errors because by default python can serialize functions but not class methods. So I used suggestion on Can't pickle <type 'instancemethod'> when using python's multiprocessing Pool.map() but the problem is that if I have some lambda expressions inside my methods it's not working. My sample code is as follows: import numpy as np from copy_reg import pickle from types import

How to solve the error which occurs when using from pickle.load() function?

六月ゝ 毕业季﹏ 提交于 2019-12-12 02:39:54
问题 I would like to load a dataset in IPython Environment and and use it. In the directory containing the dataset, I've got these files: batches.meta data_batch_1 data_batch_2 data_batch_3 data_batch_4 data_batch_5 readme test_batch I wrote this code: import os import pickle as pickle import numpy as np import matplotlib.pyplot as plt #Function Definition def load_CIFAR(ROOT): xs=[]; ys=[]; for b in range(6): f = os.path.join(ROOT, "data_batch_%d"%(b+1)); X, Y = load_CIFAR_batch(f); xs.append(X);

ValueError: could not broadcast input array from shape (22500,3) into shape (1)

蹲街弑〆低调 提交于 2019-12-12 02:24:40
问题 I relied on the code mentioned, here, but with minor edits. The version that I have is as follows: import numpy as np import _pickle as cPickle from PIL import Image import sys,os pixels = [] labels = [] traindata = [] data=[] directory = 'C:\\Users\\abc\\Desktop\\Testing\\images' for root, dirs, files in os.walk(directory): for file in files: floc = file im = Image.open(str(directory) + '\\' + floc) pix = np.array(im.getdata()) pixels.append(pix) labels.append(1) pixels = np.array(pixels)

Value Error when unpickling a file

£可爱£侵袭症+ 提交于 2019-12-12 01:49:12
问题 I have been given a file that contains two pickled objects- it was sent to me as a .pk file. I was told it had two objects, however, my attempt to unpikle these files is unsuccessful. The first pickled object contains a dictionary of pairs of numbers with their roman numerals, and the second contains dictionary pairs of roman numerals with their numbers. How can I unpickle these two dictionaries separately? This is what I have below, along with the error message I am receiving: import pickle

mpi processes working in a burst

℡╲_俬逩灬. 提交于 2019-12-12 01:45:24
问题 I am using mpi4py to model a distributed application. I have n processes accessing a shared file and writing some logs into the shared file during their execution. I notice that the logs are not uniformly written. Here is an example of how logs are written into the shared file: process0.log0 process0.log1 process0.log2 process0.log3 process0.log4 process2.log0 process2.log1 process2.log2 process1.log0 process1.log1 Ideally it should be like: process0.log0 process1.log0 process2.log0 process0

how to save a dictionary in pickle

妖精的绣舞 提交于 2019-12-12 01:44:27
问题 I'm trying to use Pickle to save a dictionary in a file. The code to save the dictionary runs without any problems, but when I try to retrieve the dictionary from the file in the Python shell, I get an EOF error: >>> import pprint >>> pkl_file = open('data.pkl', 'rb') >>> data1 = pickle.load(pkl_file) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/pickle.py", line 1378, in load return Unpickler(file).load() File "/usr/lib/python2.7/pickle.py",

Pickle variables and classes for save function in text adventure

余生颓废 提交于 2019-12-11 23:16:14
问题 I am trying to make a save function in a text adventure. The function must save some variables and parameters for the player. I have tried to Google it and asking on forums, but I can't make it work. The entire code is here: http://pastebin.com/8Y3PNnRx The saving function should save the player = player('Niels', 'Knight, 0, 0, 0, 0, 0, 0, 1) (line 417) and variables like player.gold and player.potion (line 420) at location 'C:\\Users\\XXXXX\\Desktop\\SmallDungeons\\save.dat' Thank you for