Matplotlib on legacy python install gives " cannot import name '_path' " error

Hello,

I know support for Python2 ended at the beginning of this year, but I would really appreciate some help.

I am using an old 3rd party software with built in python2 scripting but get the following error on this line “import matplotlib.pyplot as plt” " cannot import name ‘_path’ "

I am using:
Windows 10 Enterprise
M1Studio’s built in Python2 terminal
pip install --target=“C:\Program Files\M1Studio” matplotlib==2.2.5 --upgrade

Any help someone can offer would be appreciated!

Thanks,
-Michael

Can you please paste the full traceback?

Do you have any other Matplotlib versions installed? I am worried that you are seeing an effective chimera of different versions (maybe an incomplete uninstall, maybe a --user install floating around…).

Here is the full traceback of the error:

[08:55:19.504519]Traceback (most recent call last):

  File "", line 12, in <module>
  File "", line 6, in ImportMPL
  File "C:\Program Files\M1Studio\matplotlib\pyplot.py", line 31, in <module>
    import matplotlib.colorbar
  File "C:\Program Files\M1Studio\matplotlib\colorbar.py", line 32, in <module>
    import matplotlib.artist as martist
  File "C:\Program Files\M1Studio\matplotlib\artist.py", line 16, in <module>
    from .path import Path
  File "C:\Program Files\M1Studio\matplotlib\path.py", line 21, in <module>
    from . import _path, rcParams
ImportError: cannot import name '_path'


As far as I am aware of, there are not any other installations of Matplotlib anywhere on my computer.

[@tacaswell edited to add markup]

Do the _path.dlls exist?

When you installed did it pull the wheel or try to build from source?

I wasn’t able to find a file by the name _path.dll in the directory where I installed Matplotlib to…

Also based on this line from windows power shell, I believe that it pulled the wheel:
Collecting matplotlib==2.2.5
Using cached matplotlib-2.2.5-cp38-cp38-win32.whl (8.8 MB)

Ah, well that is a hint as to what is going wrong, in your original post you said you were using py2 (which I assume is python2.7) but your log says you pulled the wheel for py38.

Can you update the version of pip in your python2 environment (or make sure you use the right version of python’s pip do do the install)? Failing that you may be able to use the flags on pip install to get it to install the correct version of the wheel (see https://pip.pypa.io/en/stable/reference/pip_install/#options)

pip install --target="C:\Program Files\M1Studio" matplotlib==2.2.5 --upgrade --python-version 27

That seemed to get me one step further…

I used the command python -m pip install --target=“C:\Program Files\M1Studio” C:\Python27\Lib\ensurepip_bundled\matplotlib-2.2.5-cp27-cp27m-win32.whl --upgrade --python-version 27 --only-binary=:all:

However, I now get the following error:
[12:15:00.027531]Traceback (most recent call last):
File “”, line 12, in
File “”, line 6, in ImportMPL
File “C:\Program Files\M1Studio\matplotlib\pyplot.py”, line 31, in
import matplotlib.colorbar
File “C:\Program Files\M1Studio\matplotlib\colorbar.py”, line 32, in
import matplotlib.artist as martist
File “C:\Program Files\M1Studio\matplotlib\artist.py”, line 16, in
from .path import Path
File “C:\Program Files\M1Studio\matplotlib\path.py”, line 21, in
from . import _path, rcParams
ImportError: DLL load failed: The specified module could not be found.

Any suggestions for this?