I have the following folder hierarchy.
apriltag
python
apriltag.py
my_notebook.ipynb
I simply want to import apriltag.py into my Jupyter Notebook. I tried doing it this way..
import sys
import os.path
sys.path.append(os.path.dirname(os.path.realpath('__file__')) + "/apriltag/python")
import apriltag
However, when I try to access a class from apriltag, like so:
print(apriltag.Detector)
I get the following error:
AttributeError Traceback (most recent call last)
<ipython-input-74-d1254ec9a372> in <module>()
12 import apriltag
13
---> 14 print(apriltag.Detector)
AttributeError: module 'apriltag' has no attribute 'Detector'
Suggesting that the module was not imported correctly. I've tried creating __init__.py at the root of the python directory as well but the same thing occurred.
from apriltag import Detectorwork?dir(apriltag)will probably tell you a lot.cannot import name 'Detector'['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']not sure how to interpret itprint(apriltag.__path__), and see if it's pointing to apriltag/python/apriltag.py, or just apriltag. (Compare both the results of the dir and the path to what you'd get by inspecting sys or some other thing that imported well.dir(sys)andprint(sys.__path__)would give you an idea of what to expect when it's properly loaded.