qas2100
qas2100

Reputation: 131

matplotlib ImportError: DLL load failed while importing _cext

Matplotlib issue

How to get rid of this error when importing matplotlib (actually matplotlib.pyplot)?

ImportError: DLL load failed while importing _cext: The specified module could not be found

These are fresh Python and Pycharm installs after reinstalling Windows 10. I am using Python 3.11.2 and Pycharm Community Edition 2022.3.3

I did not experience this issue before reinstalling Windows. Most likely I've been using older versions of Python and Pycharm but not much older (don't remember which exactly), something like six to eight months old.

Upvotes: 11

Views: 33423

Answers (4)

Sergey Vturin
Sergey Vturin

Reputation: 51

Thanks to @deceze and @Keitetsu. This pip install msvc-runtime works for me too. But there is one important thing about it: it must be installed in main python, not in a venv! (even if an error occurs in the venv) It takes me a long time to realize it, and I hope this will help someone else.

Upvotes: 1

user22244964
user22244964

Reputation: 1

Check whether matplotlib library was imported twice.

Upvotes: 0

Keitetsu
Keitetsu

Reputation: 101

If pip installation of msvc-runtime does not solve the problem, please check if the Microsoft Visual C++ Redistributable package is installed.

Upvotes: 10

deceze
deceze

Reputation: 522522

Open Windows PowerShell and use this:

pip install msvc-runtime

Upvotes: 10

Related Questions