ImportError: Import by filename is not supported when unpickleing

Larry Martell larry.martell at gmail.com
Thu Jul 28 09:48:30 EDT 2016


On Thu, Jul 28, 2016 at 8:51 AM, Nobody <nobody at nowhere.invalid> 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 that you're calling Popen() incorrectly.
>
>> And when I debugged I found that this was happening in the execvp call in
>> subprocess and arg 2 was a str. So then I changed it using shell=False
>> with the command line in a string, and that is when I get the  ImportError
>> error.
>
> This is just hiding the error. Passing the command line as a string will
> result in the string being parsed in some way (the details depend upon the
> OS). Unless the string was assembled with the correct quoting, this will
> corrupt the string.
>
> I'd suggest starting off by ensuring that the string received by the child
> process is the one which you intended to pass. Calculate and display (or
> log) its hash (see the hashlib module) in both the sender and receiver and
> confirm that they're the same.

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 makes the process much easier to
debug.



More information about the Python-list mailing list