saezlab / pypath

Python module for prior knowledge integration. Builds databases of signaling pathways, enzyme-substrate interactions, complexes, annotations and intercellular communication roles.
http://omnipathdb.org/
GNU General Public License v3.0
134 stars 45 forks source link

Circular Import errors on the latest version #288

Open austinv11 opened 7 months ago

austinv11 commented 7 months ago

Describe the bug There was a circular import error that I believe was introduced by this commit: https://github.com/saezlab/pypath/commit/05f13bec48ba0a9b0174d68e60390bcabeb1ae6c

This prevents me from making use of the omnipath database.

To Reproduce Steps to reproduce the behavior:

from pypath import omnipath
op = omnipath.db.get_db('curated', ncbi_tax_id=9606)   # Circular import error here

Expected behavior No exceptions

Traceback

Traceback (most recent call last):
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 1, in <module>
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/omnipath/__init__.py", line 25, in <module>
    from pypath.omnipath import app as _app_mod
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/omnipath/app.py", line 34, in <module>
    import pypath.resources.network as netres
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/resources/network.py", line 25, in <module>
    import pypath.resources.data_formats as data_formats
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/resources/data_formats.py", line 26, in <module>
    import pypath.internals.input_formats as input_formats
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/internals/input_formats.py", line 27, in <module>
    import pypath.inputs.uniprot as uniprot_input
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/inputs/uniprot.py", line 41, in <module>
    import pypath.utils.taxonomy as taxonomy
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/utils/__init__.py", line 20, in <module>
    from . import orthology as homology
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/utils/orthology.py", line 45, in <module>
    import pypath.utils.mapping as mapping
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/utils/mapping.py", line 65, in <module>
    import pypath.internals.maps as maps
  File "/Users/austinv11/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/homebrew/anaconda3/envs/riot/lib/python3.10/site-packages/pypath/internals/maps.py", line 31, in <module>
    input_formats.UniprotMapping(
AttributeError: partially initialized module 'pypath.internals.input_formats' has no attribute 'UniprotMapping' (most likely due to a circular import)

Log file No additional logs.

Desktop (please complete the following information):

Additional context This error goes away when downgrading to 0.16.9