zktuong/dandelion

Backports error

Opened this issue · 4 comments

Description of the bug

When running session_info.show() when dandelion has been imported raises an error:

Cell In[2], line 2
      1 #Output session Info
----> 2 session_info.show()

File ~/rds/hpc-work/conda_envs/new_bio/lib/python3.11/site-packages/session_info/main.py:209, in show(na, os, cpu, jupyter, dependencies, std_lib, private, write_req_file, req_file_name, html, excludes)
    207 for mod_name in clean_modules:
    208     mod_names.append(mod_name)
--> 209     mod = sys.modules[mod_name]
    210     # Since modules use different attribute names to store version info,
    211     # try the most common ones.
    212     try:

KeyError: 'backports'

Minimal reproducible example

#Standard Imports:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib as mpl

import scanpy as sc
import dandelion as ddl
import pingouin as pg

import session_info

#Output session Info
session_info.show()

The error message produced by the code above

---------------------------------------------------------------------------
KeyError                          Traceback (most recent call last)
Cell In[2], line 2
      1 #Output session Info
----> 2 session_info.show()

File ~/rds/hpc-work/conda_envs/new_bio/lib/python3.11/site-packages/session_info/main.py:209, in show(na, os, cpu, jupyter, dependencies, std_lib, private, write_req_file, req_file_name, html, excludes)
    207 for mod_name in clean_modules:
    208     mod_names.append(mod_name)
--> 209     mod = sys.modules[mod_name]
    210     # Since modules use different attribute names to store version info,
    211     # try the most common ones.
    212     try:

KeyError: 'backports'

OS information

HPC cluster

Version information

scanpy==1.10.3 anndata==0.10.8 umap==0.5.6 numpy==2.0.2 scipy==1.14.1 pandas==2.2.3 scikit-learn==1.5.2 statsmodels==0.14.3 igraph==0.11.6 pynndescent==0.5.13

dandelion==0.3.8 pandas==2.2.3 numpy==1.26.4 matplotlib==3.9.2 networkx==3.3 scipy==1.14.1

Additional context

This is definitely caused only if importing dandelion. I have worked through each import and run session_info.show() and do not get this error until dandelion is imported.

hi there, i'm not sure what's happening since backports is not a dependency in dandelion

but just in case, can you report back what you see with pip show backports?

For example with anndata:

pip show anndata

Name: anndata
Version: 0.10.9
Summary: Annotated data.
Home-page: https://github.com/scverse/anndata
Author: Philipp Angerer, Alex Wolf, Isaac Virshup, Sergei Rybakov
Author-email: 
License: 
Location: /opt/homebrew/Caskroom/mambaforge/base/envs/dandelion/lib/python3.11/site-packages
Requires: array-api-compat, h5py, natsort, numpy, packaging, pandas, scipy
Required-by: anndata2ri, infercnvpy, kttools, milopy, mudata, palantir, sc-dandelion, scanpy, scFates, scirpy

I use conda to manage my environment (mainly).
pip show backoports reports WARNING: Package(s) not found: backports

conda list backports reports:

# Name                    Version                   Build  Channel
backports                 1.0                pyhd8ed1ab_4    conda-forge

how about
conda-tree whoneeds backports
https://anaconda.org/conda-forge/conda-tree

anyway, it's not an issue with dandelion:

>>> import dandelion
>>> import session_info
>>> session_info.show()
-----
dandelion           0.4.1.dev2
session_info        1.0.0
-----
Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:34:54) [Clang 16.0.6 ]
macOS-14.4-arm64-arm-64bit
-----
Session information updated at 2024-10-05 08:18