I have a file called tester.py
, located on /project
.
/project
has a subdirectory called lib
, with a file called BoxTime.py
:
/project/tester.py
/project/lib/BoxTime.py
I want to import BoxTime
from tester
. I have tried this:
import lib.BoxTime
Which resulted:
Traceback (most recent call last):
File "./tester.py", line 3, in <module>
import lib.BoxTime
ImportError: No module named lib.BoxTime
Any ideas how to import BoxTime
from the subdirectory?
EDIT
The __init__.py
was the problem, but don't forget to refer to BoxTime
as lib.BoxTime
, or use:
import lib.BoxTime as BT
...
BT.bt_function()
lib/BoxTime
totester
. – Assurance__init__.py
file. Check Is__init__.py
not required for packages in Python 3.3+. – Belanger