# Metaclass Conflict from trying to Import Scanpy

**URL:** https://discourse.scverse.org/t/metaclass-conflict-from-trying-to-import-scanpy/1133
**Category:** scanpy
**Created:** [February 14, 2023, 9:14am UTC](https://discourse.scverse.org/t/metaclass-conflict-from-trying-to-import-scanpy/1133 "2023-02-14T09:14:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kparakul](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/kparakul/32/405_2.png) [@kparakul](https://discourse.scverse.org/u/kparakul)
#### Post date: [February 14, 2023, 9:14am UTC](https://discourse.scverse.org/t/metaclass-conflict-from-trying-to-import-scanpy/1133/1 "2023-02-14T09:14:43Z")

</div>

Hi there! I was trying to work on my code but I am getting an import error from trying to import scanpy that I have never previously gotten. The issue is a type error with a metaclass conflict between the `Axes` class and the `SubplotBase` class.

I thought perhaps this issue was caused due to a new update in the scanpy environment and I was wondering as to why this is occurring and how I might be able to fix it. I tried installing previous versions of scanpy instead as well as the other packages but this did not resolve my issue.

My code was working perfectly fine beforehand and I have not made any changes to the code itself. Besides the issue is within the import itself. Any insight would be extremely helpful thanks so much!

This is the full error shown below:

* * *

TypeError Traceback (most recent call last)  
 in   
5 import numpy as np  
6 import pandas as pd  
----\> 7 import scanpy as sc  
8 import os  
9 import anndata

3 frames  
/usr/local/lib/python3.8/dist-packages/scanpy/ **init**.py in   
14 from . import tools as tl  
15 from . import preprocessing as pp  
—\> 16 from . import plotting as pl  
17 from . import datasets, logging, queries, external, get, metrics, experimental  
18

/usr/local/lib/python3.8/dist-packages/scanpy/plotting/ **init**.py in   
----\> 1 from .\_anndata import (  
2 scatter,  
3 violin,  
4 ranking,  
5 clustermap,

/usr/local/lib/python3.8/dist-packages/scanpy/plotting/\_anndata.py in   
26 from …\_utils import sanitize\_anndata, \_doc\_params, \_check\_use\_raw  
27 from …\_compat import Literal  
—\> 28 from . import \_utils  
29 from .\_utils import scatter\_base, scatter\_group, setup\_axes, check\_colornorm  
30 from .\_utils import ColorLike, \_FontWeight, \_FontSize

/usr/local/lib/python3.8/dist-packages/scanpy/plotting/\_utils.py in   
33  
34  
—\> 35 class \_AxesSubplot(Axes, axes.SubplotBase, ABC):  
36 “”“Intersection between Axes and SubplotBase: Has methods of both”“”  
37

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

---

<div class="post-metadata">

### Author: ![grst](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/grst/32/17_2.png) [@grst](https://discourse.scverse.org/u/grst)
#### Post date: [February 14, 2023, 2:37pm UTC](https://discourse.scverse.org/t/metaclass-conflict-from-trying-to-import-scanpy/1133/2 "2023-02-14T14:37:05Z")

</div>

See [`TypeError: metaclass conflict`: matplotlib v3.7.0 is incompatible with scanpy · Issue #2411 · scverse/scanpy · GitHub](https://github.com/scverse/scanpy/issues/2411)

To workaround, downgrade matplotlib to \<3.7

---

<div class="post-metadata">

### Author: ![kparakul](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/kparakul/32/405_2.png) [@kparakul](https://discourse.scverse.org/u/kparakul)
#### Post date: [February 14, 2023, 2:58pm UTC](https://discourse.scverse.org/t/metaclass-conflict-from-trying-to-import-scanpy/1133/3 "2023-02-14T14:58:28Z")

</div>

The people who reply on here are truly god sends, I was banging my head on the wall for hours trying to resolve this issue.

I truly, truly appreciate the help so much, thank you. 🙂

---

<div class="post-metadata">

### Author: ![Mayank05121](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/mayank05121/32/444_2.png) [@Mayank05121](https://discourse.scverse.org/u/Mayank05121)
#### Post date: [February 20, 2023, 5:56am UTC](https://discourse.scverse.org/t/metaclass-conflict-from-trying-to-import-scanpy/1133/4 "2023-02-20T05:56:59Z")

</div>

Yes thats true and it helps everyone else who might face the issue in future
