Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble importing and accessing omnipath from pypath #275

Open
hcl1216 opened this issue Dec 12, 2023 · 13 comments
Open

Trouble importing and accessing omnipath from pypath #275

hcl1216 opened this issue Dec 12, 2023 · 13 comments
Assignees
Labels
bug Problem in the code

Comments

@hcl1216
Copy link

hcl1216 commented Dec 12, 2023

Hello,

When I try importing pypath or omnipath after installing it, I keep getting AttributeError: 'NoneType' object has no attribute 'msg'. However, it works fine if I delete the the last line of init.py: info(0).


AttributeError Traceback (most recent call last)
Cell In[44], line 1
----> 1 from pypath import omnipath

File c:\Users\sundo\anaconda3\Lib\site-packages\pypath_init_.py:110
81 _session_mod.log().msg(
82 (
83 '\n'
(...)
106 wrap = False,
107 )
109 # include info at the beginning of the log:
--> 110 info(0)

File c:\Users\sundo\anaconda3\Lib\site-packages\pypath_init_.py:81, in info(loglevel)
76 def info(loglevel = -9):
77 """
78 Prints basic information about the current session.
79 """
---> 81 _session_mod.log().msg(
82 (
83 '\n'
84 '\t- session ID: %s\n'
85 '\t- working directory: %s\n'
...
105 level = loglevel,
106 wrap = False,
107 )

AttributeError: 'NoneType' object has no attribute 'msg'

In addition, further error arises when I try accessing omnipath database.


NameError Traceback (most recent call last)
Cell In[9], line 1
----> 1 cu = omnipath.db.get_db('curated')
2 cu.make_df()
3 cu.df

File c:\Users\sundo\anaconda3\Lib\site-packages\pypath\omnipath\app.py:492, in DatabaseManager.get_db(self, dataset, ncbi_tax_id)
482 def get_db(self, dataset, ncbi_tax_id = 9606):
483 """
484 Returns a dataset object. Loads and builds the dataset if necessary.
485
(...)
489 files.
490 """
--> 492 self.ensure_dataset(dataset, ncbi_tax_id = ncbi_tax_id)
494 _dataset = self._dataset_taxid(dataset, ncbi_tax_id = ncbi_tax_id)
496 return getattr(self, _dataset)

File c:\Users\sundo\anaconda3\Lib\site-packages\pypath\omnipath\app.py:136, in DatabaseManager.ensure_dataset(self, dataset, force_reload, force_rebuild, ncbi_tax_id)
128 if (
129 force_rebuild or
130 self.rebuild or
131 rebuild_dataset or
132 not self.pickle_exists(dataset, ncbi_tax_id = ncbi_tax_id)
...
--> 323 if isinstance(value, _const.LIST_LIKE) else
324 getattr(self.resource, attr) == value
325 )

NameError: name '_const' is not defined

OS: Windows
Python version: 3.11.5

Apologies if this is a simple problem,

Thank you for your help

@hcl1216 hcl1216 added the bug Problem in the code label Dec 12, 2023
@willisbillis
Copy link

I'm having a similar issue with any request to omnipath resources. Here is an example error thrown:

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://omnipathdb.org/queries/enzsub?format=json

@varunkas
Copy link

I also get a similar error when importing pypath installed with either:
pip install pypath-omnipath
or
pip install git+https://github.com/saezlab/pypath.git
The error is:
AttributeError: 'NoneType' object has no attribute 'msg'

As a result, I am unable to use:
dc.get_resource("MSigDB", organism = "mouse")

@willov
Copy link

willov commented Jan 18, 2024

I was also unable to load the database when installing through either pypi or github.

I cloned the project, and installed pypath by navigating to the root folder and ran pip install ..
Now, it appears that I can run the first step of the example:

from pypath import omnipath
op = omnipath.db.get_db('omnipath')

Note, some resources appear to be inaccessible, but that might be due to the other resources. I am attaching a log, it it is relevant to the developers.

pypath-3zsgl.log

@mcjmigdal
Copy link

mcjmigdal commented Jan 18, 2024

Same here, I landed here while working with decoupler package. Following @willov, I was able install and import pypath.

However, it seems there are further issues although I am not sure if this is related:

import pypath.share.progress as progress
ModuleNotFoundError: No module named 'pypath.share.progress'

I had a leftover installation in a different location that was causing the issue, willov workaround works for me.

@ACheccoli
Copy link

Hello, any news about this issue?

@deeenes
Copy link
Member

deeenes commented Feb 4, 2024

Hi All, Apologies for coming so late to this issue. I think a variety of independent issues pop up in this thread:

  • @hcl1216, @varunkas The initial issue has been fixed in 8292a54, however this fix hasn't propagated yet to PyPI, until now. Now the version installed by pip should work too.
  • @willisbillis I remember a short time ago there was a server side issue that caused some requests to fail with HTTP 500. Don't remember what was the reason, but pretty sure it works again now.
  • @willov Thanks for including the log, it already pointed me to some interesting errors. Interestingly, your log ends without error, was there also a traceback? Or is this an out of memory issue? Building the omnipath network dataset is a really heavy task, it includes the download of hundreds of URLs, hence it has a high chance to fail any time. We intended this module for those who want to build customized databases or access the raw data of resources directly. If you tell me what's your ultimate purpose, I can give better advice.
  • @ACheccoli - Which of the above ones? :) For the first one only had to be addressed in PyPI, which I've just done.

@varunkas
Copy link

varunkas commented Feb 5, 2024

Thank you, @deeenes . I will give it a try and update.

@deeenes deeenes self-assigned this Feb 5, 2024
@corinabioinformatic
Copy link

Hello @deeenes ! Thanks for all this great work. I installed omnipath ( 'ModuleNotFoundError: No module named toml) and pypath later, to load from there omnipath (again: 'ModuleNotFoundError: No module named toml').
After installing 'toml' with conda install toml, I came with another module lacking.
'ModuleNotFoundError: No module named pypath_common.
It points to the file pypath/share/session.py file --> line: from pypath_common import Logger.

Where could I find this missing module?

Many thanks!

@deeenes
Copy link
Member

deeenes commented Feb 7, 2024

Hi @corinabioinformatic, that's weird, both pypath_common and toml are listed as requirements for pypath-omnipath, here and here. How exactly did you install pypath, and in what kind of environment?

@corinabioinformatic
Copy link

corinabioinformatic commented Feb 8, 2024

Hi @deeenes . I basically:
1- Open Powershell terminal
2. - type WSL , so i work in linux (inside windows)
3. I follow the readme in pypath: https://github.com/saezlab/pypath?tab=readme-ov-file
create conda env
activate conda env
pip install pypath-omnipath
open python terminal inside the active env
from pypath import omnipath
op = omnipath.db.get_db('omnipath')

ERROR

@deeenes
Copy link
Member

deeenes commented Feb 12, 2024

@corinabioinformatic -- Indeed it's a question why pip hasn't installed those dependencies in this particular conda env, when I'm not aware of any other situation where these were missing. For example, if I install pypath in a new virtual env on my Linux machine:

denes@x /tmp $ cd /tmp
denes@x /tmp $ python -m venv tmpenv
denes@x /tmp $ cd tmpenv/
denes@x /tmp/tmpenv $ source ./bin/activate
(tmpenv) denes@x /tmp/tmpenv $ pip install pypath-omnipath
Collecting pypath-omnipath
  Obtaining dependency information for pypath-omnipath from https://files.pythonhosted.org/packages/47/37/aba55e9bf4177dcfea109c82f92a84cee4230f43230228eefd6cedc5ada3/pypath_omnipath-0.16.5-py3-none-any.whl.metadata
  Downloading pypath_omnipath-0.16.5-py3-none-any.whl.metadata (13 kB)
...
Collecting pypath_common>=0.2.0 (from pypath-omnipath)
  Downloading pypath_common-0.2.0.tar.gz (49 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.2/49.2 kB 2.4 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
...
Collecting toml (from pypath-omnipath)
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
...
Building wheels for collected packages: pypath_common
  Building wheel for pypath_common (pyproject.toml) ... done
  Created wheel for pypath_common: filename=pypath_common-0.2.0-py3-none-any.whl size=54966 sha256=d10ed6077d4180f1d1a93ccc04e1a289e8a1c29383199a31e0c51ff56a4527d6
  Stored in directory: /home/denes/.cache/pip/wheels/85/a7/46/7e073952fce7b53e5f97c92764673915eb18aa01b60ff4e55a
Successfully built pypath_common
Installing collected packages: ..., toml, ..., pypath_common, ..., pypath-omnipath
Successfully installed ... pypath-omnipath-0.16.5 pypath_common-0.2.0 ... toml-0.10.2 ...

However, I would try to install them manually, bc this particular situation is likely rare, and probably for you the problem will be sorted out this way:

# in your env:
pip install toml pypath_common

Apart from this, I wouldn't recommend calling pypath.omnipath.db.get_db('omnipath') for the reasons I mentioned to Willow just 5 comments above. If you let me know what do you want to use OmniPath or pypath for, I can give better advice.

Denes

@Ryeeeeeeeeee
Copy link

Hello when I run progeny = dc.get_progeny(organism='mouse', top=500), there is an error :
WARNING:root:Traceback (most recent call last):
File "/opt/conda/envs/decoupler/lib/python3.9/site-packages/decoupler/omnip.py", line 648, in translate_net
ImportError: cannot import name 'orthology' from 'pypath.utils' (/opt/conda/envs/decoupler/lib/python3.9/site-packages/pypath/utils/init.py)

WARNING:root:pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git
/opt/conda/envs/decoupler/lib/python3.9/site-packages/decoupler/_misc.py:22: UserWarning: pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git
warnings.warn(msg)

ImportError Traceback (most recent call last)
File /opt/conda/envs/decoupler/lib/python3.9/site-packages/decoupler/omnip.py:648, in translate_net(net, columns, source_organism, target_organism, id_type, unique_by, **kwargs)
647 import pypath
--> 648 from pypath.utils import orthology
649 from pypath.share import common

ImportError: cannot import name 'orthology' from 'pypath.utils' (/opt/conda/envs/decoupler/lib/python3.9/site-packages/pypath/utils/init.py)

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
Cell In[26], line 1
----> 1 progeny = dc.get_progeny(organism='mouse', top=500)
2 progeny

File /opt/conda/envs/decoupler/lib/python3.9/site-packages/decoupler/omnip.py:214, in get_progeny(organism, top, **kwargs)
210 p = op._misc.dtypes.auto_dtype(p)
212 if not _is_human(organism):
--> 214 p = translate_net(
215 p,
216 columns='target',
217 source_organism=9606,
218 target_organism=organism,
219 )
221 return p.reset_index(drop=True)

File /opt/conda/envs/decoupler/lib/python3.9/site-packages/decoupler/omnip.py:671, in translate_net(net, columns, source_organism, target_organism, id_type, unique_by, **kwargs)
666 msg = (
667 'pypath-omnipath is not installed. Please install it with: '
668 'pip install git+https://github.com/saezlab/pypath.git style="color:rgb(175,0,0)">'
669 )
670 _misc.log_traceback(msg)
--> 671 raise ImportError(msg)
673 _source_organism = taxonomy.ensure_ncbi_tax_id(source_organism)
674 _target_organism = taxonomy.ensure_ncbi_tax_id(target_organism)

ImportError: pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git

However, after I install pypath-omnipath as it suggested, I still got the same error, and pypath-omnipath was in pip list.
How can I solve this problem?

Many thanks!

@deeenes
Copy link
Member

deeenes commented Mar 3, 2024

Hello @Ryeeeeeeeeee, see here, especially the last few comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Problem in the code
Projects
None yet
Development

No branches or pull requests

9 participants