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

When importing Scanpy 1.9.1, if you're using matplotlib version below 3.7, you might encounter a metaclass error. #3029

Closed
3 tasks done
12hsk opened this issue Apr 25, 2024 · 9 comments

Comments

@12hsk
Copy link

12hsk commented Apr 25, 2024

Please make sure these conditions are met

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the main branch of scanpy.

What happened?

导入scanpy1.9.1时,matplotlib在3.7版本以下然后发生元类错误

Minimal code sample

import scanpy as sc

Error output

Traceback (most recent call last):
  File "G:/stmgcn-main/stmgcn-main/STMGCN/DLPFC.py", line 15, in <module>
    from util import *
  File "G:\stmgcn-main\stmgcn-main\STMGCN\util.py", line 1, in <module>
    import scanpy as sc
  File "E:\Anaconda3\envs\stmgcn\lib\site-packages\scanpy\__init__.py", line 16, in <module>
    from . import plotting as pl
  File "E:\Anaconda3\envs\stmgcn\lib\site-packages\scanpy\plotting\__init__.py", line 1, in <module>
    from ._anndata import (
  File "E:\Anaconda3\envs\stmgcn\lib\site-packages\scanpy\plotting\_anndata.py", line 28, in <module>
    from . import _utils
  File "E:\Anaconda3\envs\stmgcn\lib\site-packages\scanpy\plotting\_utils.py", line 35, in <module>
    class _AxesSubplot(Axes, axes.SubplotBase, ABC):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

进程已结束,退出代码1

Versions

You can't get to on account of the crash.scanpy.logging.print_versions()

@12hsk 12hsk added the Bug 🐛 label Apr 25, 2024
@12hsk 12hsk changed the title 导入scanpy1.9.1时,matplotlib在3.7版本以下然后发生元类错误 When importing Scanpy 1.9.1, if you're using matplotlib version below 3.7, you might encounter a metaclass error. Apr 25, 2024
@flying-sheep
Copy link
Member

@ivirshup time to set minimum versions for scanpy? I can help this time, you don’t have to go through this alone again

@12hsk
Copy link
Author

12hsk commented Apr 25, 2024

是时候为 ScanPy 设置最低版本了吗?这次我可以帮忙,你不必再独自经历这件事了

How to solve this problem?

@flying-sheep
Copy link
Member

@12hsk
Copy link
Author

12hsk commented Apr 25, 2024

My Anaconda prompts that I can't install Scanpy above 1.10 or Matplotlib above 3.8.

@flying-sheep
Copy link
Member

Both are available on conda forge. I might be able to help if you show me

  1. the command and environment file you used
  2. the output (in English: you can use e.g. env LANG=C conda ... for that)

Please format everything as a code block and don’t just paste it into the comment box, see here

@frederikziebell
Copy link

Dear scverse authors (@flying-sheep, @LucaMarconato et al.), because of issues like these, maybe think about a sophisticated staging environment a la Bioconductor to ensure that packages are compatible with each other. If you do a conda install scanpy that finishes without any error, it cannot be that import scanpy fails with an error resulting from an incompatible matplotlib version.

@flying-sheep
Copy link
Member

What you describe doesn‘t need to happen, and you can fix this!

  1. go to https://github.com/conda-forge/conda-forge-repodata-patches-feedstock/
  2. make a PR that patches conda’s dependency data to include this constraint
  3. the problem is gone

@frederikziebell
Copy link

For me, it was a different combination of versions, I guess Scanpy 1.9.8 and matplotlib 3.8 that caused the error. It's not about fixing specific instances but the problem of version mismatches of complex interacting software packages in general. And this has to run in an automated fashion.

@LucaMarconato
Copy link
Member

@frederikziebell thanks for the feedback, we will discuss this in the next core meeting. An automated cross-package CI could be a solution.

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

4 participants