I'm working on a project, and have the following directory structure:
Classifier_Code/
classifier/
__init__.py
Event.py
classifier.py
lib/
__init__.py
categories.txt
test.py
The file __init__.py
inside lib/
reads a list of several hundred category names from categories.txt
and stores them in a list, which I then want to import into classifier.py
using the statement
from lib import CATEGORY_LIST
However, when doing so, I get the following error:
Traceback (most recent call last):
File "classifier/classifier.py", line 1, in <module>
from lib import CATEGORIES
File "classifier/lib/__init__.py", line 3, in <module>
with open('categories.txt') as categories:
IOError: [Errno 2] No such file or directory: 'categories.txt'
That is, when I'm trying to import the module, I get an error because the text file categories.txt
is going along with it.
Does anyone know a fix for this specific problem?