This problem has confused me for days.
I have two files, helpers.py and launcher.py.
In helpers.py I have defined the function hello(), which prints "hello".
I want to call hello() in launcher.py.
This is what I wrote in launcher.py:
from helpers import hello
....
helpers.hello()
But when I run it, I get this:
from helpers import hello
ImportError: No module named helpers
How do I fix this?
Edit in response to answers / comments
- I'm using OS X and Python 3.4
- The two files are in the same directory
I tried the two ways:
from helpers import hello hello()and
import helpers helpers.hello()But still this bug:
import helpers ImportError: No module named 'helpers'
I think there should be something wrong in the CLASSPATH of Terminal.
Second edit
The problem highlighted in these answers was an issue, but in the end resetting the classpath resolved.