Re: ImportError: Import by filename is not supported when unpickleing

2016-07-28 Thread Lutz Horn
Hi, Am 07/28/2016 um 03:48 PM schrieb Larry Martell: Thanks, but I have abandoned using pickle. I am now converting my objects to JSON, writing them to files, passing the file names to the process and reading them in and converting them back to objects there. In addition to that working, it make

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-28 Thread Larry Martell
On Thu, Jul 28, 2016 at 8:51 AM, Nobody wrote: > On Wed, 27 Jul 2016 22:47:15 -0400, Larry Martell wrote: > >> Also let me add that initially I was calling Popen with shell=False and >> the arguments in a list, and that was failing with: >> >> arg 2 must contain only strings > > That indicates tha

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-28 Thread Nobody
On Wed, 27 Jul 2016 22:47:15 -0400, Larry Martell wrote: > Also let me add that initially I was calling Popen with shell=False and > the arguments in a list, and that was failing with: > > arg 2 must contain only strings That indicates that you're calling Popen() incorrectly. > And when I debug

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-28 Thread Larry Martell
On Thu, Jul 28, 2016 at 1:58 AM, Steven D'Aprano wrote: > On Thursday 28 July 2016 12:39, Larry Martell wrote: > >> I have an object of type Target: >> >> (Pdb) type(target) >> >> >> And I pickle it like this: >> >> (Pdb) type(pickle.dumps(target)) >> >> >> And then it looks like this: >> >> (Pd

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-27 Thread Steven D'Aprano
On Thursday 28 July 2016 12:39, Larry Martell wrote: > I have an object of type Target: > > (Pdb) type(target) > > > And I pickle it like this: > > (Pdb) type(pickle.dumps(target)) > > > And then it looks like this: > > (Pdb) pickle.dumps(target) > "ccopy_reg\n_reconstructor\np0\n(cworkite

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-27 Thread Larry Martell
On Wed, Jul 27, 2016 at 10:39 PM, Larry Martell wrote: > On Wed, Jul 27, 2016 at 7:45 PM, Jason Benjamin wrote: >> Look at this: https://wiki.python.org/moin/UsingPickle >> It uses *pickle.dump* not *pickle.dumps* > > Yes that uses a file. I do not want to use a file. I want to pass the > object

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-27 Thread Larry Martell
On Wed, Jul 27, 2016 at 7:45 PM, Jason Benjamin wrote: > Look at this: https://wiki.python.org/moin/UsingPickle > It uses *pickle.dump* not *pickle.dumps* Yes that uses a file. I do not want to use a file. I want to pass the object as a string. > If you still don't get it send me the code for th

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-27 Thread Larry Martell
On Wed, Jul 27, 2016 at 6:54 PM, Jason Benjamin wrote: > If it has and 's' on the end it will only work on strings. *dumps* refers > to a string too. Yes, I know. I have an object, which I pickle with dumps, which turns it into a string. Then I try to unpickle it with loads and I get that error.

Re: ImportError: Import by filename is not supported when unpickleing

2016-07-27 Thread Jason Benjamin
On Wed, 27 Jul 2016 17:25:43 -0400, Larry Martell wrote: > When I try and unpickle an object with pickle.loads it fails with: > > ImportError: Import by filename is not supported when unpickleing > > I've never used pickle before. Why do I get this and how can I fix it? Try using *pickle.load*