Issue 1:
Bug report

Bug summary

On some Windows machines (including Windows 10 and Windows 7), we experienced ImportError: DLL load failed: The specific module could not be found after upgrading from Matplotlib 3.3.0 to 3.3.1.

Code for reproduction

import matplotlib would trigger the import error while trying to import ft2font.

Actual outcome

In [1]: import matplotlib
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-0484cd13f94d> in <module>
----> 1 import matplotlib

c:\users\nzlab\envs\nta-1465\lib\site-packages\matplotlib\__init__.py in <module>
172
173
--> 174 _check_versions()
175
176

c:\users\nzlab\envs\nta-1465\lib\site-packages\matplotlib\__init__.py in _check_versions()
157 # Quickfix to ensure Microsoft Visual C++ redistributable
158 # DLLs are loaded before importing kiwisolver
--> 159 from . import ft2font
160
161 for modname, minver in [

ImportError: DLL load failed: The specified module could not be found.

Expected outcome

No error should be presented.

Matplotlib version

Operating system: Windows 7 (64bit), Windows 10 (64bit)

Matplotlib version: 3.3.1

Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg

Python version: Python 3.7.6

Jupyter version (if applicable):

Other libraries: Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.27.29016 NOT INSTALLED

**Further diagnose shows: **

ft2font.cp37-win_amd64.pyd (Matplotlib 3.3.0) links VCRUNTIME140.dll

ft2font.cp37-win_amd64.pyd (Matplotlib 3.3.1) links VCRUNTIME140_1.dll

Those computers which have DLL load failed don't have VCRUNTIME140_1.dll in DLL search path.

Solution

Installing the latest Visual Studio 2015, 2019 and 2019 redistributable should address the issue.

Question

Is changing in VC++ API (from 14 to 14.1) an intentional move on Matplotlib 3.3.1 for Windows release? If so, should the VC++ dependency to be added to Installation Guide?

Issue 2:
Bug summary

importing matplotlib on a fresh Windows machine or container fails with the following traceback:

>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\lib\site-packages\matplotlib\__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "C:\Python\lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Python\lib\site-packages\matplotlib\colors.py", line 56, in <module>
from matplotlib import _api, _cm, cbook, scale
File "C:\Python\lib\site-packages\matplotlib\scale.py", line 22, in <module>
from matplotlib.ticker import (
File "C:\Python\lib\site-packages\matplotlib\ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "C:\Python\lib\site-packages\matplotlib\transforms.py", line 49, in <module>
from matplotlib._path import (
ImportError: DLL load failed while importing _path: The specified module could not be found.

AFAIK, the DLL that's being called for isn't displayed here but I suspect this is something from the MSVC runtime.

Code for reproduction

docker run -it python:3.11.1-windowsservercore-1809 powershell
pip install matplotlib
python
import matplotlib

Actual outcome

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\lib\site-packages\matplotlib\__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "C:\Python\lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Python\lib\site-packages\matplotlib\colors.py", line 56, in <module>
from matplotlib import _api, _cm, cbook, scale
File "C:\Python\lib\site-packages\matplotlib\scale.py", line 22, in <module>
from matplotlib.ticker import (
File "C:\Python\lib\site-packages\matplotlib\ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "C:\Python\lib\site-packages\matplotlib\transforms.py", line 49, in <module>
from matplotlib._path import (
ImportError: DLL load failed while importing _path: The specified module could not be found.

Expected outcome

matplotlib imports without errors.

Additional information

I think the MSVC runtime is currently a dependency of matplotlib and the required DLL should be distributed with the wheel. If I run pip install msvc-runtime the import works, maybe that package or something like it could be a transient OS-specific dependency.

Operating system

Windows 10

Matplotlib Version

Import fails (3.6.2, 3.6.1, 3.6.0)

Matplotlib Backend

Unknown, import fails

Python version

3.11.1

Jupyter version

N/A

Installation

pip