pypath
pypath copied to clipboard
Exception about circular imports
Describe the bug
I'm getting circular import issues from other parts of the pypath while developing disgenet.py
. I installed it in three different ways but I'm getting an error about circular imports. One of my coworkers tried my code in her machine and it worked. It's probably about the version I'm trying to install.
To Reproduce
Steps to reproduce the behavior:
1.a Run pip install git+https://github.com/saezlab/pypath.git@nobiocypher
from terminal
1.b Run pip install pypath-omnipath-0.13.11.tar.gz
from terminal
1.b Run pip install pypath-omnipath-0.14.3.tar.gz
from terminal
1.b Run pip install pypath-omnipath
from terminal
2. Run "disgenet.py"
Expected behavior My code to work as it did on my coworker's machine.
Traceback
For 1.a
Traceback (most recent call last):
File "/home/username/star/pypath/pypath/inputs/disgenet.py", line 28, in <module>
import pypath.share.curl as curl
File "/home/username/.local/lib/python3.10/site-packages/pypath/__init__.py", line 34, in <module>
from pypath._metadata import __version__, __author__, __license__
File "/home/username/.local/lib/python3.10/site-packages/pypath/_metadata.py", line 33, in <module>
import importlib.metadata
File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 17, in <module>
from . import _adapters, _meta
File "/usr/lib/python3.10/importlib/metadata/_adapters.py", line 3, in <module>
import email.message
File "/usr/lib/python3.10/email/message.py", line 15, in <module>
from email import utils
File "/usr/lib/python3.10/email/utils.py", line 40, in <module>
from email.charset import Charset
File "/usr/lib/python3.10/email/charset.py", line 15, in <module>
import email.quoprimime
File "/usr/lib/python3.10/email/quoprimime.py", line 44, in <module>
from string import ascii_letters, digits, hexdigits
File "/home/username/star/pypath/pypath/inputs/string.py", line 31, in <module>
import pypath.resources.urls as urls
File "/home/username/.local/lib/python3.10/site-packages/pypath/resources/__init__.py", line 25, in <module>
from . import controller as _controller_mod
File "/home/username/.local/lib/python3.10/site-packages/pypath/resources/controller.py", line 32, in <module>
import pypath.share.session as session_mod
File "/home/username/.local/lib/python3.10/site-packages/pypath/share/session.py", line 30, in <module>
import pypath.share.log as log
File "/home/username/.local/lib/python3.10/site-packages/pypath/share/log.py", line 32, in <module>
import timeloop
File "/home/username/.local/lib/python3.10/site-packages/timeloop/__init__.py", line 1, in <module>
from timeloop.app import Timeloop
File "/home/username/.local/lib/python3.10/site-packages/timeloop/app.py", line 1, in <module>
import logging
File "/usr/lib/python3.10/logging/__init__.py", line 28, in <module>
from string import Template
ImportError: cannot import name 'Template' from partially initialized module 'string' (most likely due to a circular import) (/home/username/star/pypath/pypath/inputs/string.py)
or something like that for 1.b
Traceback (most recent call last):
File "/home/username/star/pypath/pypath/inputs/disgenet.py", line 28, in <module>
import pypath.share.curl as curl
File "/home/username/.local/lib/python3.10/site-packages/pypath/__init__.py", line 35, in <module>
import pypath.share.session as _session_mod
File "/home/username/.local/lib/python3.10/site-packages/pypath/share/session.py", line 29, in <module>
import pypath.share.log as log
File "/home/username/.local/lib/python3.10/site-packages/pypath/share/log.py", line 31, in <module>
import timeloop
File "/home/username/.local/lib/python3.10/site-packages/timeloop/__init__.py", line 1, in <module>
from timeloop.app import Timeloop
File "/home/username/.local/lib/python3.10/site-packages/timeloop/app.py", line 1, in <module>
import logging
File "/usr/lib/python3.10/logging/__init__.py", line 28, in <module>
from string import Template
File "/home/username/star/pypath/pypath/inputs/string.py", line 31, in <module>
import pypath.resources.urls as urls
File "/home/username/.local/lib/python3.10/site-packages/pypath/resources/__init__.py", line 24, in <module>
from . import controller as _controller_mod
File "/home/username/.local/lib/python3.10/site-packages/pypath/resources/controller.py", line 33, in <module>
import pypath.internals.resource as resource_base
File "/home/username/.local/lib/python3.10/site-packages/pypath/internals/resource.py", line 35, in <module>
import pypath.inputs as inputs
File "/home/username/.local/lib/python3.10/site-packages/pypath/inputs/__init__.py", line 28, in <module>
_logger = session.Logger(name = 'inputs')
AttributeError: partially initialized module 'pypath.share.session' has no attribute 'Logger' (most likely due to a circular import)
Desktop (please complete the following information):
- OS: Linux 5.15.50-1-lts x86_64
- Python version: 3.10.5
I've updated this issue several times so if you've looked at it before, please look at it again as I've made it better to understand and fix things.
The module pypath.inputs.disgenet
is not designed to be run as a script – though it would be possible and maybe useful to make it so. Instead, it can be used in a script or interactively:
from pypath.inputs import disgenet
d = disgenet.disgenet_annotations()
Or can be accessed by the core.annot
module:
from pypath.core import annot
d = annot.Disgenet()