admin管理员组

文章数量:1122846

Had this error

    {
    "name": "ImportError",
    "message": "cannot import name '_c_internal_utils' from partially initialized module 'matplotlib' (most likely due to a circular import) (c:\\Users\\Lenovo\\miniconda3\\envs\\lastresort\\Lib\\site-packages\\matplotlib\\__init__.py)",
    "stack": "---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[3], line 2
      1 import os
----> 2 import matplotlib.pyplot as plt
      3 from matplotlib.pyplot import imshow
      5 import numpy as np

File c:\\Users\\Lenovo\\miniconda3\\envs\\lastresort\\Lib\\site-packages\\matplotlib\\__init__.py:159
    155 from packaging.version import parse as parse_version
    157 # cbook must import matplotlib only within function
    158 # definitions, so it is safe to import from it here.
--> 159 from . import _api, _version, cbook, _docstring, rcsetup
    160 from matplotlib.cbook import sanitize_sequence
    161 from matplotlib._api import MatplotlibDeprecationWarning

File c:\\Users\\Lenovo\\miniconda3\\envs\\lastresort\\Lib\\site-packages\\matplotlib\\cbook.py:32
     29     from numpy import VisibleDeprecationWarning
     31 import matplotlib
---> 32 from matplotlib import _api, _c_internal_utils
     35 def _get_running_interactive_framework():
     36     \"\"\"
     37     Return the interactive framework whose event loop is currently running, if
     38     any, or \"headless\" if no event loop can be started, or None.
   (...)
     44         \"macosx\", \"headless\", ``None``.
     45     \"\"\"

ImportError: cannot import name '_c_internal_utils' from partially initialized module 'matplotlib' (most likely due to a circular import) (c:\\Users\\Lenovo\\miniconda3\\envs\\lastresort\\Lib\\site-packages\\matplotlib\\__init__.py)"
}

and checked every other question existing like this but has different conditions. Before downgrading to python 3.11 matplotlib still works, I need to downgrade to 3.11 because 3.12 and 3.13 has requirement error (tensorflow-cpu in not exist in 3.12, cgi not exist since 3.11 or something that needs me to downgrade from 3.13)

Reinstalled Matplotlib and update it and still not working

Checked other forum this might be OS related and related to C++ engines, any possible solution?

Had this error

    {
    "name": "ImportError",
    "message": "cannot import name '_c_internal_utils' from partially initialized module 'matplotlib' (most likely due to a circular import) (c:\\Users\\Lenovo\\miniconda3\\envs\\lastresort\\Lib\\site-packages\\matplotlib\\__init__.py)",
    "stack": "---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[3], line 2
      1 import os
----> 2 import matplotlib.pyplot as plt
      3 from matplotlib.pyplot import imshow
      5 import numpy as np

File c:\\Users\\Lenovo\\miniconda3\\envs\\lastresort\\Lib\\site-packages\\matplotlib\\__init__.py:159
    155 from packaging.version import parse as parse_version
    157 # cbook must import matplotlib only within function
    158 # definitions, so it is safe to import from it here.
--> 159 from . import _api, _version, cbook, _docstring, rcsetup
    160 from matplotlib.cbook import sanitize_sequence
    161 from matplotlib._api import MatplotlibDeprecationWarning

File c:\\Users\\Lenovo\\miniconda3\\envs\\lastresort\\Lib\\site-packages\\matplotlib\\cbook.py:32
     29     from numpy import VisibleDeprecationWarning
     31 import matplotlib
---> 32 from matplotlib import _api, _c_internal_utils
     35 def _get_running_interactive_framework():
     36     \"\"\"
     37     Return the interactive framework whose event loop is currently running, if
     38     any, or \"headless\" if no event loop can be started, or None.
   (...)
     44         \"macosx\", \"headless\", ``None``.
     45     \"\"\"

ImportError: cannot import name '_c_internal_utils' from partially initialized module 'matplotlib' (most likely due to a circular import) (c:\\Users\\Lenovo\\miniconda3\\envs\\lastresort\\Lib\\site-packages\\matplotlib\\__init__.py)"
}

and checked every other question existing like this but has different conditions. Before downgrading to python 3.11 matplotlib still works, I need to downgrade to 3.11 because 3.12 and 3.13 has requirement error (tensorflow-cpu in not exist in 3.12, cgi not exist since 3.11 or something that needs me to downgrade from 3.13)

Reinstalled Matplotlib and update it and still not working

Checked other forum this might be OS related and related to C++ engines, any possible solution?

Share Improve this question asked Nov 22, 2024 at 10:44 RedSeanRedSean 338 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Fixed by uninstalling matplotlib and installing matplotlib again in usual way, if necessary, delete files in ./miniconda3/envs/{env-name}/Lib/site-packages/

Will gladly edit if other details are found by other people or means

本文标签: python 3xImport Error Matplotlib require 39cinternalutils39 and actually using condaStack Overflow