Importing the re module fails

Discussion in 'Python' started by Andreas Waldenburger, Dec 7, 2008.

  1. This is a little puzzling.


    Using ipython:

    [wildemar@localhost Logstuff]$ ipython
    Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
    Type "copyright", "credits" or "license" for more information.

    [snip ipython help message]

    In [1]: import re


    This works fine. But with the regular python interpreter I get this:

    [wildemar@localhost Logstuff]$ python
    Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
    [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more
    information.
    >>> import re

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.5/re.py", line 10, in <module>
    # AB ().
    AttributeError: 'module' object has no attribute 'compile'


    What gives? Has Fedora-10 botched python or does anybody else have that
    problem es well?

    /W

    --
    My real email address is constructed by swapping the domain with the
    recipient (local part).
    Andreas Waldenburger, Dec 7, 2008
    #1
    1. Advertising

  2. Andreas Waldenburger schrieb:
    > This is a little puzzling.
    >
    >
    > Using ipython:
    >
    > [wildemar@localhost Logstuff]$ ipython
    > Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
    > Type "copyright", "credits" or "license" for more information.
    >
    > [snip ipython help message]
    >
    > In [1]: import re
    >
    >
    > This works fine. But with the regular python interpreter I get this:
    >
    > [wildemar@localhost Logstuff]$ python
    > Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
    > [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
    > Type "help", "copyright", "credits" or "license" for more
    > information.
    > >>> import re

    > Traceback (most recent call last):
    > File "<stdin>", line 1, in <module>
    > File "/usr/lib/python2.5/re.py", line 10, in <module>
    > # AB ().
    > AttributeError: 'module' object has no attribute 'compile'
    >
    >
    > What gives? Has Fedora-10 botched python or does anybody else have that
    > problem es well?


    In my re.py module on line 10, there is no import - it has way to much
    comments on the module beginning.

    So - how does your /usr/lib/python2.5/re.py look like? And what about
    some modules lying around (potentially *pycs) that mask system modules?

    Diez
    Diez B. Roggisch, Dec 7, 2008
    #2
    1. Advertising

  3. On Sun, 07 Dec 2008 20:36:58 +0100 "Diez B. Roggisch"
    <> wrote:

    > Andreas Waldenburger schrieb:
    > > This is a little puzzling.
    > >
    > >
    > > Using ipython:
    > >
    > > [wildemar@localhost Logstuff]$ ipython
    > > Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
    > > Type "copyright", "credits" or "license" for more information.
    > >
    > > [snip ipython help message]
    > >
    > > In [1]: import re
    > >
    > >
    > > This works fine. But with the regular python interpreter I get this:
    > >
    > > [wildemar@localhost Logstuff]$ python
    > > Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
    > > [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
    > > Type "help", "copyright", "credits" or "license" for more
    > > information.
    > > >>> import re

    > > Traceback (most recent call last):
    > > File "<stdin>", line 1, in <module>
    > > File "/usr/lib/python2.5/re.py", line 10, in <module>
    > > # AB ().
    > > AttributeError: 'module' object has no attribute 'compile'
    > >
    > >
    > > What gives? Has Fedora-10 botched python or does anybody else have
    > > that problem es well?

    >
    > In my re.py module on line 10, there is no import - it has way to
    > much comments on the module beginning.
    >
    > So - how does your /usr/lib/python2.5/re.py look like?

    Just like the error message says: " # AB ()." on
    line ten. That's what confused me so much (among being confused anyway).

    > And what
    > about some modules lying around (potentially *pycs) that mask system
    > modules?
    >

    Bullseye. I had a re.pyc in the current directory, because I stupidly
    created a testbed called re.py. Realizing my folly I renamed it to
    something else, while forgetting to delete the already created re.pyc.

    Thanks, and sorry for the noise. (I do wonder why ipython didn't
    complain, though.)


    /W
    --
    My real email address is constructed by swapping the domain with the
    recipient (local part).
    Andreas Waldenburger, Dec 7, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MK
    Replies:
    4
    Views:
    793
  2. plb
    Replies:
    2
    Views:
    345
  3. Pradnyesh Sawant

    doubt with importing module, given module name

    Pradnyesh Sawant, Apr 9, 2007, in forum: Python
    Replies:
    0
    Views:
    281
    Pradnyesh Sawant
    Apr 9, 2007
  4. -ecosys.com
    Replies:
    4
    Views:
    302
    Calvin Spealman
    Sep 28, 2007
  5. Helmut Jarausch

    importing site fails - why?

    Helmut Jarausch, Nov 12, 2010, in forum: Python
    Replies:
    3
    Views:
    464
    Stefan Sonnenberg-Carstens
    Nov 12, 2010
Loading...

Share This Page