[Python-bugs-list] [ python-Bugs-784786 ] ImportError: cannot
import name OptionParser
SourceForge.net
noreply at sourceforge.net
Fri Aug 8 14:56:33 EDT 2003
Bugs item #784786, was opened at 2003-08-07 10:01
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=784786&group_id=5470
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Lu Jian Xiong (fdmulti)
Assigned to: Neal Norwitz (nnorwitz)
Summary: ImportError: cannot import name OptionParser
Initial Comment:
E:\>optparse.py
Traceback (most recent call last):
File "E:\Home\optparse.py", line 1, in ?
from optparse import OptionParser
File "E:\Home\optparse.py", line 1, in ?
from optparse import OptionParser
ImportError: cannot import name OptionParser
E:\>type optparse.py
from optparse import OptionParser
E:\>type optparse.txt
Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200
32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more
information.
******************************************
**********************
Personal firewall software may warn about the
connection IDLE
makes to its subprocess using this computer's internal
loopback
interface. This connection is not visible on any
external
interface and no data is sent to or received from the
Internet.
******************************************
**********************
IDLE 1.0
>>> from optparse import OptionParser
>>> # ok? why?
>>>
E:\>
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-08-08 16:56
Message:
Logged In: YES
user_id=33168
I'm going to assume the problem was the filename, so close
this bug. If you still have the problem, you can reopen or
add a comment.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2003-08-07 22:57
Message:
Logged In: YES
user_id=33168
I think I just realized what's happening. You are using a
file named optparse.py which you are also trying to import
within the file. Try renaming your optparse.py to a
different name. If that doesn't work, there's more
questions below which I started to ask before I realized this.
How about printing sys.path? Are they different between
IDLE and python?
If you do this, do you get the same results?
python optparse.py
Also print the current directory:
import os.path, os
print os.path.abspath(os.curdir)
My current guess is that sys.path is different.
----------------------------------------------------------------------
Comment By: Lu Jian Xiong (fdmulti)
Date: 2003-08-07 21:47
Message:
Logged In: YES
user_id=751249
E:\>optparse.py
2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)]
2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)]
Traceback (most recent call last):
File "E:\Home\Home\jxlu\optparse.py", line 3, in ?
from optparse import OptionParser
File "E:\Home\Home\jxlu\optparse.py", line 3, in ?
from optparse import OptionParser
ImportError: cannot import name OptionParser
E:\>type optparse.py
import sys
print sys.version
from optparse import OptionParser
E:\>type test1.txt
Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
**********************************************
******************
Personal firewall software may warn about the connection
IDLE
makes to its subprocess using this computer's internal
loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the
Internet.
**********************************************
******************
IDLE 1.0
>>> import sys
>>> from optparse import OptionParser
>>> # ok!
E:\>type test2.txt
Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
**********************************************
******************
Personal firewall software may warn about the connection
IDLE
makes to its subprocess using this computer's internal
loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the
Internet.
**********************************************
******************
IDLE 1.0 ==== No Subprocess ====
>>> import sys
>>> print sys.version
2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)]
>>> from optparse import OptionParser
Traceback (most recent call last):
File "<pyshell#2>", line 1, in ?
from optparse import OptionParser
ImportError: cannot import name OptionParser
>>>
E:\>
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2003-08-07 10:22
Message:
Logged In: YES
user_id=33168
Do you have have multiple versions of Python installed on
your machine? Could the first example be using the wrong
version?
What if you do this before trying to import optparse?
import sys; print sys.version
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=784786&group_id=5470
More information about the Python-bugs-list
mailing list