Strange re problem on OSX but Not Linux

Brian bnblazer at gmail.com
Wed Nov 8 13:01:44 EST 2006


I have a very small script:

import re

text = open('eq.txt','r').read()
regex = '[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]'
pattern = re.compile(regex)
match = pattern.findall(text)

print ''.join(match)

However, when I try to run it, I get this error:

Traceback (most recent call last):
  File
"/Applications/Komodo.app/Contents/SharedSupport/dbgp/bin/pydbgp", line
66, in <module>
    import dbgp.client
  File
"/Applications/Komodo.app/Contents/SharedSupport/dbgp/pythonlib/dbgp/client.py",
line 44, in <module>
    import traceback, re
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 5, in <module>
    #
AttributeError: 'module' object has no attribute 'compile'

-------------------------------------------------------------------------------
Here is the error outside of Komodo:

Traceback (most recent call last):
  File "reg1.py", line 1, in <module>
    import re
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 5, in <module>
    #
AttributeError: 'module' object has no attribute 'compile'
------------------------------------------------------------------------------

This is running 2.5 on my OSX box.  If I run it (again with 2.5) on my
SUSE machine, I get no errors.

I am sure that I have overlooked something trivial here - so please be
gentle if it is on the stupid side of things.

Thanks,
Brian




More information about the Python-list mailing list