0

I've my main code in addon.py

In the same folder, there is video.py

In addon.py I do

import video

video.play(params)

In video.py

print 'loaded'

def play(params)
   ..... [omitted code]

When executing, I got an error, because

Error Contents: 'module' object has no attribute 'play'

Also: the print is NOT executed.

What's wrong ? It seems that the module is not loaded, but if I try to add a syntax error to the file, the compiler warn me about it, so I'm a lot confused

I tried to rename to my_video, and the error is the same

11
  • 2
    You could write a print statement in video.py to see if it's imported. Commented Sep 19, 2013 at 7:59
  • I Added print "bla bla" to video.py but it's not executed. Commented Sep 19, 2013 at 8:05
  • 1
    There might be a standard module interfering with your import, trying using another name. Commented Sep 19, 2013 at 8:06
  • 1
    why would raspberry use python 2.1? Commented Sep 19, 2013 at 8:13
  • 1
    add empty __init__.py there. Commented Sep 19, 2013 at 8:14

1 Answer 1

2

In the directory with addon.py and video.py modules add an empty __init__.py file to define the package.

+- your_package/
        |- __init__.py  
        |- addon.py
        |- video.py

Python packages

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.