I'm trying to import a utilities file but running into a weird error only when I run the code through a script.
When I run test.py
location: /home/amourav/Python/proj/test.py
code:
import os
os.chdir(r'/home/amourav/Python/')
print os.listdir(os.getcwd())
print os.getcwd()
from UTILS import *
The output is:
['UTILS_local.py','UTILS.py', 'proj', 'UTILS.pyc']
/home/amourav/Python
Traceback (most recent call last): File "UNET_2D_AUG17.py", line 11, in from UTILS import * ImportError: No module named UTILS
but when I run the code through the bash terminal, it seems to work fine
bash-4.1$ python
>>> import os
>>> os.chdir(r'/home/amourav/Python/')
>>> print os.listdir(os.getcwd())
['UTILS_local.py','UTILS.py', 'proj', 'UTILS.pyc']
>>> from UTILS import *
blah blah -everything is fine- blah blah
I'm running Python 2.7.10 on a linux machine