Python module import works for one file, crashing for another

I have a very strange problem. I have three files, the first contains a base class from which classes in two other files are inherited.

The strange thing: yesterday everything went well, but today one of the files no longer works. In the meantime, I did not touch on imports.

.
└── orangecontrib
    ├──__init__.py
    └── prototypes
        ├──__init__.py
        └── widgets
            ├──__init__.py
            ├── owpythagorastree.py
            ├── owclassificationpythagorastree.py
            └── owregressionpythagorastree.py

So, the classification and regression classes must be inherited from the base class, and the import is performed in exactly the same way:

owclassificationpythagorastree.py

...
from orangecontrib.prototypes.widgets.owpythagorastree import OWPythagorasTree
...

owregressionpythagorastree.py

...
from orangecontrib.prototypes.widgets.owpythagorastree import OWPythagorasTree
...

However, when I try to run two scripts from the command line (using python owregressionpythagorastree.py), the regression widget works fine, but the classification widget causes the following error:

Traceback ( ): "owclassificationpythagorastree.py", 6,     from orangecontrib.prototypes.widgets.owpythagorastree import OWPythagorasTree ImportError: 'orangecontrib.prototypes'

, . , , .

, python virtualenv, ( pip install -e . ).

, , , , .


import sys; print(sys.path) , diff . , .

[ '///DEV/orange3-/orangecontrib//', '///DEV/orange3', '/home/pavlin/dev/orange3env/lib/python3.5/site-packages/setuptools_git-1.1-py3.5.egg', '///DEV/-', '/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', '///DEV/orange3-', '/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']

+4
2

, - , python .

( , , import mymodule, , , , from . import mymodule), :

  • .
  • PYTHONPATH .
  • , .

, :

import sys
print(sys.path)

, , , __init__.py - , .

, :

.
└── orangecontrib
    ├── __init__.py
    └── prototypes
        ├── __init__.py
        └── widgets
            ├── __init__.py
            ├── owpythagorastree.py
            ├── owclassificationpythagorastree.py
            └── owregressionpythagorastree.py

, python orangecontrib/prototypes/widgets/owclassificationpythagorastree.py ., , PYTHONPATH, python .

widgets, , , PYTHONPATH.

, , , script, ! python, , python, . , .

+2

. ? , - , .

+1

All Articles