Why optparse wont import?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Karlo Lozovina

    #1

    Why optparse wont import?

    If I create a file with only one line:

    ---
    from optparse import OptionParser
    ---

    I get this when I try to run it from "DOS" prompt:

    Traceback (most recent call last):
    File "optparse.p y", line 1, in ?
    from optparse import OptionParser
    File "X:\data\other\ source\python\p opulation\optpa rse.py", line 1, in ?
    from optparse import OptionParser
    ImportError: cannot import name OptionParser

    When I try to do that from Python prompt everything works fine. What's the
    problem?

    --
    _______ Karlo Lozovina - Mosor
    | | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
    | || _ | _ | Parce mihi domine quia Dalmata sum.
    |__|_|__||_____ |_____|
  • Jorge Godoy

    #2
    Re: Why optparse wont import?

    Karlo Lozovina <_karlo_@_mosor .net_> writes:
    [color=blue]
    > If I create a file with only one line:
    >
    > ---
    > from optparse import OptionParser
    > ---
    >
    > I get this when I try to run it from "DOS" prompt:
    >
    > Traceback (most recent call last):
    > File "optparse.p y", line 1, in ?
    > from optparse import OptionParser
    > File "X:\data\other\ source\python\p opulation\optpa rse.py", line 1, in ?
    > from optparse import OptionParser
    > ImportError: cannot import name OptionParser
    >
    > When I try to do that from Python prompt everything works fine. What's the
    > problem?[/color]

    Rename your file to something other than optparse.py...

    --
    Jorge Godoy <godoy@ieee.org >

    "Quidquid latine dictum sit, altum sonatur."
    - Qualquer coisa dita em latim soa profundo.
    - Anything said in Latin sounds smart.

    Comment

    • Karlo Lozovina

      #3
      Re: Why optparse wont import?

      Jorge Godoy <godoy@ieee.org > wrote in news:87ek328o1o .fsf@ieee.org:
      [color=blue]
      > Rename your file to something other than optparse.py...[/color]

      Oh my :(... I'm so ashamed :).

      --
      _______ Karlo Lozovina - Mosor
      | | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
      | || _ | _ | Parce mihi domine quia Dalmata sum.
      |__|_|__||_____ |_____|

      Comment

      • Steve Holden

        #4
        Re: Why optparse wont import?

        Karlo Lozovina wrote:[color=blue]
        > Jorge Godoy <godoy@ieee.org > wrote in news:87ek328o1o .fsf@ieee.org:
        >
        >[color=green]
        >>Rename your file to something other than optparse.py...[/color]
        >
        >
        > Oh my :(... I'm so ashamed :).
        >[/color]
        Don't worry. If this list had a FAQ, that would be on it. You are by no
        means the first ...

        regards
        Steve
        --
        Steve Holden +44 150 684 7255 +1 800 494 3119
        Holden Web LLC www.holdenweb.com
        PyCon TX 2006 www.python.org/pycon/

        Comment

        Working...