I'm facing a very strange problem. I've got three files, the first contains the base class, from which the classes in the other two files inherit from.
The strange thing is, everything worked fine yesterday, but one of the files doesn't work anymore today. I haven't touched the imports in the meantime.
.
└── orangecontrib
├──__init__.py
└── prototypes
├──__init__.py
└── widgets
├──__init__.py
├── owpythagorastree.py
├── owclassificationpythagorastree.py
└── owregressionpythagorastree.py
So the classification and regression classes need to inherit from the base class, and the imports are done in the exact same way:
owclassificationpythagorastree.py
...
from orangecontrib.prototypes.widgets.owpythagorastree import OWPythagorasTree
...
owregressionpythagorastree.py
...
from orangecontrib.prototypes.widgets.owpythagorastree import OWPythagorasTree
...
Yet when I try to run the two scripts from the command line (with python owregressionpythagorastree.py
) the regression widget works fine, but the classification widget produces the following error:
Traceback (most recent call last): File "owclassificationpythagorastree.py", line 6, in from orangecontrib.prototypes.widgets.owpythagorastree import OWPythagorasTree ImportError: No module named 'orangecontrib.prototypes'
This has happened several times in other projects as well, but it eventually sorts itself out. But it bothers me that I don't know what is causing this.
I did try running this both from my regular machine and a python virtualenv, where I have the module installed (I did this with pip install -e .
in the base directory).
I see no apparent reason for this behaviour and it is bothering me a lot, so any help or insight as to why this is happening and how to fix it would be appreciated.
EDIT
As requested, I ran import sys; print(sys.path)
at the top of both scripts, and after running it through diff, they are both completely identical. Nevertheless, I am posting the results here.
['/home/pavlin/dev/orange3-prototypes/orangecontrib/prototypes/widgets', '/home/pavlin/dev/orange3', '/home/pavlin/dev/orange3env/lib/python3.5/site-packages/setuptools_git-1.1-py3.5.egg', '/home/pavlin/dev/orange-bio', '/home/pavlin/dev/orange3env/lib/python3.5/site-packages/pyqtgraph-0.9.10-py3.5.egg', '/home/pavlin/dev/orange3env/lib/python3.5/site-packages/requests-2.9.1-py3.5.egg', '/home/pavlin/dev/orange3env/lib/python3.5/site-packages/slumber-0.7.1-py3.5.egg', '/home/pavlin/dev/orange3env/lib/python3.5/site-packages/Genesis_PyAPI-1.2.0-py3.5.egg', '/usr/lib/python3.5/site-packages/qt_graph_helpers-0.1.3-py3.5-linux-x86_64.egg', '/home/pavlin/dev/orange3-prototypes', '/usr/lib/python3.5/site-packages', '/home/pavlin/dev/orange3env/lib/python35.zip', '/home/pavlin/dev/orange3env/lib/python3.5', '/home/pavlin/dev/orange3env/lib/python3.5/plat-linux', '/home/pavlin/dev/orange3env/lib/python3.5/lib-dynload', '/usr/lib64/python3.5', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-linux', '/home/pavlin/dev/orange3env/lib/python3.5/site-packages', '/usr/lib/python3.5/site-packages/setuptools-18.7.1-py3.5.egg', '/home/pavlin/.local/lib/python3.5/site-packages']
__init__.py
files in each directory. I'll add them to the question, to avoid confusion. This cannot be the issue, since the modules clearly work for one of the files, but not the other. – Pavlinfrom .owpythagorastree import OWPythagorasTree
? Or even without the dot? – OneCricketeerparent module '' not loaded
error in both cases. – Pavlin