python newb has problem with import statements

D

danielmcbrearty

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:
Traceback (most recent call last):

if I do this
Traceback (most recent call last):

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
 
P

Peter Otten

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:

The file with the contents given above is clearly not the one that is
imported here,
['__builtins__', '__doc__', '__file__', '__name__']

as __all__, muxer, audio etc. are missing.

Maybe you have created a test script 'pymedia.py' in the working directory?
You can check what file you are dealing with by entering

If that is 'whatever/site-packages/pymedia/__init__.pyc' I'm guessing wrong.
Otherwise removing that file (probably 'pymedia.pyc') and the corresponding
source (pymedia.py) should fix your problem.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top