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

ImportError: cannot import name '_non_reducing_slice' from 'pandas.core.indexing' #168

Closed
jos4uke opened this issue Jan 13, 2021 · 7 comments

Comments

@jos4uke
Copy link

jos4uke commented Jan 13, 2021

Hi

I recently installed gimmemotifs (see version below) using conda as recommended.
Installation step went well without any errors.
But then calling bash gimme motifs -h to test installation got me this error: "ImportError: cannot import name '_non_reducing_slice' from 'pandas.core.indexing'" (see Error logs below).

Seems pandas has removed the leading underscore to the offending function and replaced _non_reducing_slice by non_reducing_slice as shown in their repo here

Patching report.py with the new function name fixed it.

Please, can you fix it by replacing the function by its new name in report.py?

Thanks in advance

@jos4uke

To Reproduce
Please see Installation information section to reproduce.

Expected behavior
calling help on gimme motifs using the -h switch should have returned the expected help message:

# expected help message
# gimme motifs -h
Matplotlib is building the font cache; this may take a moment.
usage: gimme [-h] <subcommand> [options] motifs [-h] [-b BACKGROUND] [-g GENOME] [--denovo] [--known] [--noreport] [--rawscore] [--nogc]
                                                [-N INT] [-p PFMFILE] [-t N] [-a ANALYSIS] [-k] [-S] [-f FRACTION] [-s N]
                                                INPUT OUTDIR

positional arguments:
  INPUT                 FASTA, BED, narrowPeak or region file.
  OUTDIR                Output directory.

optional arguments:
  -h, --help            show this help message and exit
  -b BACKGROUND, --background BACKGROUND
                        Background type (random,genomic,gc,promoter,custom) or a file with background sequences (FASTA, BED or regions)
  -g GENOME             Genome name or fasta file
  --denovo              Only use de novo motifs
  --known               Only use known motifs
  --noreport            Don't create a HTML report.
  --rawscore            Don't z-score normalize motif scores
  --nogc                Don't use GC% bins
  -N INT, --nthreads INT
                        Number of threads (default 12)

optional arguments for known motifs:
  -p PFMFILE            PFM file with motifs.(default: JASPAR2020_plants.pfm)

optional arguments for de novo motifs:
  -t N, --tools N       Tools to use, any combination of MDmodule,MEME,MEMEW,Weeder,GADEM,MotifSampler,Trawler,Improbizer,BioProspector,Posm
                        o,ChIPMunk,AMD,HMS,Homer,XXmotif,ProSampler,DiNAMO (default MEME,BioProspector,Homer)
  -a ANALYSIS, --analysis ANALYSIS
                        Analysis type: small, medium, large, xl (xl)
  -k, --keepintermediate
                        Don't delete intermediate files
  -S, --singlestrand    Only predict motifs for single + strand (default is both)
  -f FRACTION, --fraction FRACTION
                        Fraction of peaks to use for motif predicton (0.2)
  -s N, --size N        Region size to use for motif prediction (200). Set to 0 to use the size of the input regions.

Error logs

# gimme motifs -h
Matplotlib is building the font cache; this may take a moment.
Traceback (most recent call last):
  File "/opt/share/FLOCAD/userspace/jtran1/miniconda3/envs/gimmemotifs/bin/gimme", line 8, in <module>
    from gimmemotifs.cli import cli
  File "/opt/share/FLOCAD/userspace/jtran1/miniconda3/envs/gimmemotifs/lib/python3.8/site-packages/gimmemotifs/__init__.py", line 61, in <module>
    from . import denovo      # noqa: F401
  File "/opt/share/FLOCAD/userspace/jtran1/miniconda3/envs/gimmemotifs/lib/python3.8/site-packages/gimmemotifs/denovo.py", line 52, in <module>
    from gimmemotifs.report import create_denovo_motif_report
  File "/opt/share/FLOCAD/userspace/jtran1/miniconda3/envs/gimmemotifs/lib/python3.8/site-packages/gimmemotifs/report.py", line 19, in <module>
    from pandas.core.indexing import _non_reducing_slice
ImportError: cannot import name '_non_reducing_slice' from 'pandas.core.indexing' (/opt/share/FLOCAD/userspace/jtran1/miniconda3/envs/gimmemotifs/lib/python3.8/site-packages/pandas/core/indexing.py)

Installation information:

  • OS: Linux node7 4.19.0-13-amd64 bug with prediction #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
  • Installation: bash mamba create -n gimmemotifs python=3 gimmemotifs
  • Versions:
    • python 3.8.6 hffdb5ce_4_cpython conda-forge
    • gimmemotifs 0.15.2 py38h0213d0e_0 bioconda
@simonvh
Copy link
Member

simonvh commented Jan 14, 2021

Thanks for reporting, will be fixed in the next release.

@mdozmorov
Copy link

mdozmorov commented Apr 2, 2021

Had the same error with conda installation, as of Apr 2, 2021. Manually changing _non_reducing_slice to non_reducing_slice in report.py helps:

vim /Users/miniconda3/envs/gimme/lib/python3.8/site-packages/gimmemotifs/report.py

Hope it'll be fixed in the conda release.

@simonvh
Copy link
Member

simonvh commented Apr 13, 2021

After loads of trouble with the bioconda build system, version 0.15.3 (where this is fixed) is now available via conda.

@simonvh simonvh closed this as completed Apr 13, 2021
@hschult
Copy link

hschult commented Aug 2, 2021

With the newest pandas versions (1.3.0 onwards) the function is now located in pandas.io.formats.style.
See here

@tzhu-bio
Copy link

I installed with v0.16.1. It also has the same error.
How to deal with it?

@oalmelid
Copy link

oalmelid commented Nov 8, 2021

I've hit this too, while trying to run the unit tests. I've added another try-catch to import non_reducing slice from pandas.io.formats.style to my own branch as a temporary fix, but I'm not sure I'd like to have a cascading tree of try-catches to get a function import. Maybe it would be better to add some logic based on pandas.__version__, or require pandas > 1.3.0 for the next release?

@laserson
Copy link
Contributor

Is it possible to reopen this issue? I am coming across this too

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

No branches or pull requests

7 participants