tgbugs / ontquery

a framework querying ontology terms
MIT License
3 stars 3 forks source link

bug in class imports #14

Closed dbkeator closed 5 years ago

dbkeator commented 5 years ago

Hi,

When using this library after import import ontquery as oq

Python complains with the following error. I think it's the relative import in services.py (from .interlex_client import InterLexClient):

Connected to pydev debugger (build 183.5429.31) /anaconda3/lib/python3.7/site-packages/fuzzywuzzy/fuzz.py:11: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning') Traceback (most recent call last): File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1741, in main() File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1735, in main globals = debugger.run(setup['file'], None, None, is_module) File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1135, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/Users/dbkeator/Documents/Coding/PyNIDM/nidm/experiment/tools/CSV2NIDM.py", line 276, in main(sys.argv[1:]) File "/Users/dbkeator/Documents/Coding/PyNIDM/nidm/experiment/tools/CSV2NIDM.py", line 105, in main column_to_terms = map_variables_to_terms(df=df, apikey=args.key, directory=dirname(args.output_file), output_file=args.output_file, json_file=args.json_map, owl_file=args.owl) File "/Users/dbkeator/Documents/Coding/PyNIDM/nidm/experiment/Utils.py", line 531, in map_variables_to_terms ilx_obj = InitializeInterlexRemote(key=apikey) File "/Users/dbkeator/Documents/Coding/PyNIDM/nidm/experiment/Utils.py", line 339, in InitializeInterlexRemote InterLexRemote = oq.plugin.get('InterLex') File "/anaconda3/lib/python3.7/site-packages/ontquery-0.0.5-py3.7.egg/ontquery/plugin.py", line 40, in get File "/anaconda3/lib/python3.7/site-packages/ontquery-0.0.5-py3.7.egg/ontquery/plugin.py", line 22, in getClass File "/anaconda3/lib/python3.7/site-packages/ontquery-0.0.5-py3.7.egg/ontquery/plugins/services.py", line 6, in ModuleNotFoundError: No module named 'ontquery.plugins.interlex_client'

dbkeator commented 5 years ago

Here's another example of the bug:

Python 3.7.0 (default, Jun 28 2018, 07:39:16) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ontquery as oq
>>> InterLexRemote = oq.plugin.get('InterLex')
Traceback (most recent call last):
  File "/Users/dbkeator/Documents/Coding/ontquery/ontquery/plugins/services.py", line 9, in <module>
    from pyontutils import scigraph
ModuleNotFoundError: No module named 'pyontutils'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/dbkeator/Documents/Coding/ontquery/ontquery/plugin.py", line 40, in get
    return _plugins[name].getClass()
  File "/Users/dbkeator/Documents/Coding/ontquery/ontquery/plugin.py", line 22, in getClass
    module = __import__(self.module_path, globals(), locals(), [""])
  File "/Users/dbkeator/Documents/Coding/ontquery/ontquery/plugins/services.py", line 11, in <module>
    from . import scigraph_client as scigraph
ImportError: cannot import name 'scigraph_client' from 'ontquery.plugins' (/Users/dbkeator/Documents/Coding/ontquery/ontquery/plugins/__init__.py)
dbkeator commented 5 years ago

Ok, I believe I figured it out. I needed to separately install pyonutils:

https://github.com/tgbugs/pyontutils