[Pythonmac-SIG] python 2.7 problem with crcmod -- "ImportError: No module named predefined"
Ronald Oussoren
ronaldoussoren at mac.com
Tue May 3 12:34:59 CEST 2011
On 3 May, 2011, at 10:37, Brendan Simon (eTRIX) wrote:
>
>
> On 3/05/11 5:01 PM, Ronald Oussoren wrote:
>> The crcmod package contains a module named crcmod. My guess is that
>> both py2app and py2exe get confused by this and try to fetch
>> 'crcmod.predefined' from the nested module instead of the toplevel
>> package. This basicly means that both py2*s have a bug in their
>> emulation of the __import__ code.
>>>>
>>>> I'll see if I can create a testcase for this for the modulegraph
>>>> package, it should then be fairly easy to actually fix the issue. As
>>>> this is only a problem with python2.7 this may end up being a bug in
>>>> the stdlib though.
>>>>
>>>> As a workaround try adding includes for crcmod.predefined, or even
>>>> the entire crcmod package (setup(..., package=['crcmod'], ...))
>>>
>>> Yep. Forcing inclusion of the module in setup does resolve the
>>> issue. Here is the snippet of my setup file that worked for me :)
>>>
>>> Hopefully py2app can be fixed so this is not necessary, but at least
>>> I have a workaround now.
>>
>> I think I can fix this in modulegraph, I'm not quite sure why it works
>> in 2.6 but not in 2.7 though. Are you using the same version of crcmod
>> in both cases?
>>
>> My current impresssion of what's going on here: crcmod.__init__ contains:
>>
>> try:
>> from crcmod.crcmod import *
>> import crcmod.predefined
>> except ImportError:
>> # Make this backward compatible
>> from crcmod import *
>> import predefined
>>
>> A test with a simular package structure fails on both 2.6 and 2.7, but
>> works with 3.2. Modulegraph fails because it creates a MissingModule
>> node for crcmod.predefined, which seems to indicate a bug in how we
>> process imports in a package as it should have created a MissingModule
>> node for crcmod.crcmod.predefined for the second import statement and
>> then a real node for the last one.
> Ah, yes, there are different versions of crcmod installed.
>
> $ /Library/Frameworks/Python.framework/Versions/2.5/bin/pip freeze |
> grep crcmod
> crcmod==1.5
>
> $ /Library/Frameworks/Python.framework/Versions/2.6/bin/pip freeze |
> grep crcmod
> crcmod==1.6.1
>
> $ /Library/Frameworks/Python.framework/Versions/2.7/bin/pip freeze |
> grep crcmod
> crcmod==1.7
That explains the difference in behaviour. I've pushed a fix to the bitbucket repository (at http://bitbucket.org/ronaldoussoren/modulegraph) that should fix this issue.
I'll push out a new release of modulegraph when I've done some more testing.
Ronald
>
> -- Brendan.
> _______________________________________________
> Pythonmac-SIG maillist - Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2224 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20110503/744ac624/attachment.bin>
More information about the Pythonmac-SIG
mailing list