Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31722

error executing "import html.parser" from a script

Date 2012-10-19 13:15 +0400
Subject error executing "import html.parser" from a script
From Paul Volkov <capt-obvious@yandex.ru>
Newsgroups comp.lang.python
Message-ID <mailman.2500.1350638147.27098.python-list@python.org> (permalink)

Show all headers | View raw


What is this madness?
I have Python 3.3.0 installed on Windows XP. I do not have Python 2
(but I had it before). I do the following steps:

1. Import from an interactive session (no problems)

>python
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import html
>>> import html.parser
>>> ^Z

2. Import from command line (no problems)

>python -c "import html.parser"

3. Import from a script. The script contains only one import line.
Everything else is commented out.

>python e:\tmp\pyt\html.py
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1512, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "e:\tmp\pyt\html.py", line 7, in <module>
    import html.parser
  File "e:\tmp\pyt\html.py", line 7, in <module>
    import html.parser
ImportError: No module named 'html.parser'; html is not a package

4. And then I tried to print sys.path from my script by modifying it this way:
import sys
print (sys.path)
import html.parser

And the result is: (I don't know why sys.path is printed twice)

>python e:\tmp\pyt/html.py
['e:\\tmp\\pyt', 'D:\\WINDOWS\\system32\\python33.zip',
'D:\\Python33\\DLLs', 'D:\\Python33\\lib', '
D:\\Python33', 'D:\\Python33\\lib\\site-packages']
['e:\\tmp\\pyt', 'D:\\WINDOWS\\system32\\python33.zip',
'D:\\Python33\\DLLs', 'D:\\Python33\\lib', '
D:\\Python33', 'D:\\Python33\\lib\\site-packages']
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1512, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "e:\tmp\pyt/html.py", line 8, in <module>
    import html.parser
  File "e:\tmp\pyt\html.py", line 8, in <module>
    import html.parser
ImportError: No module named 'html.parser'; html is not a package

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

error executing "import html.parser" from a script Paul Volkov <capt-obvious@yandex.ru> - 2012-10-19 13:15 +0400
  Re: error executing "import html.parser" from a script Hans Mulder <hansmu@xs4all.nl> - 2012-10-19 12:48 +0200

csiph-web