python newb has problem with import statements
danielmcbrearty at gmail.com
danielmcbrearty at gmail.com
Sun Mar 19 04:45:49 EST 2006
Hi
Old hand at perl, giving python a try. Trying to get pymedia running on
my winxp box.
Have installed activestate python 2.4 and pymedia using precompiled
installers.
Problem is it SEEMS that the __init__.py is not getting run when I
import a module.
So, I have pymedia installed and it imports fine:
>>> import pymedia
>>> dir(pymedia)
['__builtins__', '__doc__', '__file__', '__name__']
>>>
the init file looks like this:
(docs and comments skipped)
print "in pymedia" # added by me to see
__all__= [ 'muxer', 'audio', 'video', 'removable' ]
import muxer, audio, video, removable
but I can't import submodules of pymedia:
>>> import pymedia.sound
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
ImportError: No module named sound
>>>
if I do this
>>> from pymedia import *
>>> import pymedia.sound
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
ImportError: No module named sound
>>>
the weird thing is teh IDE (pythonwin) knows about the sub modules - it
shows them in the auto-suggest thingy when I type "pymedia."
so what's going on? do I have an install problem? (I did try removing
and reinstalling, no avail) am I just misunderstanding how this should
work?
all helpful stuff much appreciated
Daniel
More information about the Python-list
mailing list