This might be a repetition , but anyway straightly related to imports in python.
I have a directory structure like follows:
Main /
sample.py
utils / preprocess.py , __init__.py
Data / stopwords.txt
In sample.py
from utils import preprocess
In preprocess.py
import codecs
stopwords_ = codecs.open('../Data/stopwords.txt' , encoding='utf-8')
stopwords_ = stopwords_.readlines()
Now the error is when I run sample.py IOError: [Errno 2] No such file or directory: '../Data/stopwords.txt' . I understand the crux of the error , because when I print the os.getcwd() in preprocess.py I get '/home/username/Main' .
But how to solve it . Any help would be appreciated