467,861 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,861 developers. It's quick & easy.

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.py", line 1, in ?
from optparse import OptionParser
File "X:\data\other\source\python\population\optparse.p y", 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.
|__|_|__||_____|_____|
Jan 20 '06 #1
  • viewed: 2275
Share:
3 Replies
Karlo Lozovina <_karlo_@_mosor.net_> writes:
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.py", line 1, in ?
from optparse import OptionParser
File "X:\data\other\source\python\population\optparse.p y", 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?


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

--
Jorge Godoy <go***@ieee.org>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Jan 20 '06 #2
Jorge Godoy <go***@ieee.org> wrote in news:87************@ieee.org:
Rename your file to something other than optparse.py...


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

--
_______ Karlo Lozovina - Mosor
| | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
| || _ | _ | Parce mihi domine quia Dalmata sum.
|__|_|__||_____|_____|
Jan 21 '06 #3
Karlo Lozovina wrote:
Jorge Godoy <go***@ieee.org> wrote in news:87************@ieee.org:

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

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

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/

Jan 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Andres Corrada-Emmanuel | last post: by
8 posts views Thread by Hans-Joachim Widmaier | last post: by
5 posts views Thread by Norbert Thek | last post: by
3 posts views Thread by Dan | last post: by
5 posts views Thread by john.m.roach | last post: by
reply views Thread by Robert Kern | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.