472,794 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,794 software developers and data experts.

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
3 2415
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andres Corrada-Emmanuel | last post by:
Hi, I'm getting a conflict between options defined between two different scripts and I'm wondering if it is a bug or the intended effect. script foo: <def some_function> <define some...
8
by: Hans-Joachim Widmaier | last post by:
I was really pleased when the Optik module found its way into the standard Python battery compartment, as it matched all my option parsing requirements. But, as always, there's really nothing that...
3
by: washu | last post by:
Hi, I'm was going through the module help located on http://docs.python.org/lib/optparse-store-action.html and I tried modifying it a tiny bit and things don't work. If someone could tell me...
5
by: Norbert Thek | last post by:
Hi I'm using Python 24 on Windows > (2k) Is there an easy way to convince optparse to accept newline in the helpstring? and more importand also in the 'desc' string. I tried everything (from...
5
by: Bob | last post by:
I'm playing around with optparse and created the code below. How do I move that to a function and what variable do I pass? >From the documentation it seems like "options.optparse_test" would have...
2
by: mbeachy | last post by:
Some rather unexpected behavior in the set_default/set_defaults methods for OptionParser that I noticed recently: <Option at 0x-483b3414: -r/--restart> {'restart': None} {'retart': False,...
3
by: Dan | last post by:
I've been using optparse for a while, and I have an option with a number of sub-actions I want to describe in the help section: parser.add_option("-a", "--action", help=\ """Current supported...
5
by: john.m.roach | last post by:
I'm trying to implement some simple command line options. Some of the 'help' sections are long and I would like to control line breaks. How do you do this? Thanks!
0
by: Robert Kern | last post by:
Jeff Keasler wrote: If you code it up with unit tests and documentation, it has a good chance. But in the meantime, you can tell optparse to stop processing options using the standard "--"...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.