ImportError: Import by filename is not supported when unpickleing

Larry Martell larry.martell at gmail.com
Wed Jul 27 19:30:03 EDT 2016


On Wed, Jul 27, 2016 at 6:54 PM, Jason Benjamin <hexusnexus at gmail.com> 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.


(Pdb) type(args.target)
<type 'str'>
(Pdb) pickle.loads(args.target)
*** ImportError: Import by filename is not supported.


> On Wed, Jul 27, 2016 at 3:44 PM, Larry Martell <larry.martell at gmail.com>
> wrote:
>
>
>
> On Wednesday, July 27, 2016, Jason Benjamin <hexusnexus at gmail.com> wrote:
>>
>> 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* instead of *pickle.loads*.  pickle.loads is for
>> strings.  Retrieved from documentation: help(pickle) after importing
>> pickle.
>
>
> I am unpickling a string created with pickle.dumps



More information about the Python-list mailing list