biolab / orange-bio

Other
9 stars 32 forks source link

Relative import in python3 #72

Open cheral opened 8 years ago

cheral commented 8 years ago

@ajdapretnar

In OWFeatureSelection.py

from .utils import gui as guiutils
from .utils import group as grouputils
from .utils.settings import SetContextHandler`

we don't need to do the relative path .utils because utils and python script are in the same directory.

I was getting an error while trying to import Similar to this one : http://stackoverflow.com/questions/16637428/relative-import-in-python-3-not-working

instead it should be

from utils import gui as guiutils
from utils import group as grouputils
from utils.settings import SetContextHandler`

This needs to be solved before solving issue https://github.com/biolab/orange-bio/issues/71

ajdapretnar commented 8 years ago

Thanks for reporting the issue! For me, Differential Gene Expression works fine (no error). I think @markotoplak should also look at this (he's a pro on this add-on).

ales-erjavec commented 8 years ago

The imports are correct-ish. OWFeatureSelection is part of a python package. In general the file will not be run as a python script with the containing directory set as the current working dir (or anywhere on PYTHONPATH). Therefor the imports need to be either explicitly relative (.utils) or fully qualified (orangecontrib.bio.widgets3.utils)

Note that the the preferred way to invoke a file (within a package) as a script is using the python -m command (i.e. python -m orangecontrib.bio.widgets3.OWFeatureSelection)

cheral commented 8 years ago

@ales-erjavec The way you suggested should work as mentioned here But I am still facing the same problem screenshot from 2016-05-31 10-46-01

kernc commented 8 years ago

Try again:

pip install -e .  # install orange-bio
cd /              # move somewhere else
python -m orangecontrib.bio.widgets3.OWFeatureSelection