18

I have Windows 7.

For some reason, f2tfont.cpp does not compile when installing matplotlib (through pip), hence, the matplotlib install fails. Also, the matplotlib installer cannot find a Python installation.

See comments here for further details on the problem.

Community
  • 1
  • 1
bzm3r
  • 3,113
  • 6
  • 34
  • 67

13 Answers13

23

These following commands worked for me. I think problem is with the new matplotlib version 3.3.1. I downgraded to matplotlib 3.0.3.

I uninstalled the newer version, then reopen command prompt and installed matplotlib 3.0.3. It's worked for me. I am not sure if it will work for you, so I recommend to check out the discussion.

pip uninstall matplotlib
pip install matplotlib==3.0.3
drops
  • 1,524
  • 1
  • 11
  • 20
code_conundrum
  • 529
  • 6
  • 12
  • 2
    On Windows 10, using virtual env with miniconda, and python 3.7, down grading to matplotlib-3.0.3 worked for me. – Vizag Aug 18 '20 at 05:42
  • 1
    Someone hand this person a medal. Out of all the internet's solution this simple one did the job. Thank you so much. – Pramesh Bajracharya Aug 19 '20 at 09:34
  • Things changed. Your method does not work now. ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Consider an update to your answer? – xidchen Nov 24 '20 at 03:25
9

This solves my problem

As a workaround until matplotlib 3.1.1 is released, you could install this package msvc-runtime using the following command:

pip install msvc-runtime
NearHuscarl
  • 66,950
  • 18
  • 261
  • 230
5

This worked for me on Windows 10 (using the Anaconda prompt):

pip uninstall matplotlib
pip install --upgrade matplotlib
Hagbard
  • 3,430
  • 5
  • 28
  • 64
5

You need to have Visual Studio c++ in Your System.

Install Visual Studio 2019 with c++ distributions .

It worked perfectly for me.

findtharun
  • 136
  • 1
  • 4
  • 2
    installing visual studio c++ is what fixed it for me (win10, python 3.9.1, matplotlib 3.3.3) direct link to visual studio c++ x64 download [here](https://aka.ms/vs/16/release/vc_redist.x64.exe) – awadhesh14 Mar 22 '21 at 09:06
  • Worked for me as well, (win10, python 3.7.4, matplotlib 3.2.1) – user1455613 Sep 14 '21 at 07:15
5

This worked for me on Windows 10:

pip install matplotlib==3.2.1
derloopkat
  • 6,232
  • 16
  • 38
  • 45
vramires
  • 51
  • 1
  • 1
4

As specified in PEP 11, a Python release only supports a Windows platform while Microsoft considers the platform under extended support. This means that Python 3.7 supports Windows Vista and newer. If you require Windows XP support then please install Python 3.4.

  1. For Python 3.6+ you need to have Windows Service Pack 1 installed.

enter image description here

In case Windows Service Pack isn't installed. You can download Windows 7 Service Pack 1 (SP1) manually from here or also you can download it from Windows Update of Windows 7.

  1. Python needs the Microsoft C runtime for Visual Studio 2015, especially the file ucrtbase.dll.

    enter image description here

So, you need to install Microsoft Visual C++ redistribution 2015 from here.

You don't need to install Microsoft Visual Studio just C++ redistributions of 2015 will do the job.

Zahid Khan
  • 2,130
  • 2
  • 18
  • 31
3

I had this issue and then uninstalled and reinstalled conda, and updated all packages through conda. But the issue persisted. I then did a conda uninstall of the offending package (in my case, this error appeared for both matplotlib and h5py), and then pip installed them. This seemed to have fixed the issue. Strangely, it would only give this error through the console. When run through a Jupyter notebook, I didn't see this error. Must be some difference between IPython and python.

2

If you get this error by just importing matplotlib, you probably have a botched matplotlib installation. Did you compile it yourself (which I find very hard to do) or did you use a binary installer from the official page (which works like a charm, as long as you installed the dependencies beforehand)?

DO NOT USE pip for installing matplotlib and numpy, but use it for all other dependencies. This may change in the future as soon as wheels arecoming out for matplotlib.

Python console output on a Windows box:

>>> matplotlib.__version__
'1.3.1'
>>> from matplotlib import ft2font
>>>
nepix32
  • 3,012
  • 2
  • 14
  • 29
  • I used the [python(x,y)](https://code.google.com/p/pythonxy/) installer to get `matplotlib`. I know it's not a problem with the installer because I used the same installer on another computer, and everything works fine. How would you suggest I go about fixing my botched install? – bzm3r Jun 16 '14 at 20:55
  • I have no experience with python(x,y) (I contemplated it once but found no real advantage over installing everything by hand). You should update your original question by mentioning python(x,y). I would try to uninstall python(x,y) completely (delete remnants on the file system by hand, if necessary) and start from fresh. If the problem persists, you could try another python distribution like anaconda. – nepix32 Jun 16 '14 at 21:14
  • I just really like Spyder to be honest. Nothing has come close to beating it for me, in terms of user experience. – bzm3r Jun 16 '14 at 21:17
  • That's funny because Spyder has been the worst python experience ever (worse than IDLE) and I have been happy with PyDev since. Maybe I should try it again. But back to your problem: Have you tried reinstalling at least matplotlib package for python(x,y)? – nepix32 Jun 16 '14 at 22:28
  • Sigh. I tried uninstalling the matplotlib package. I couldn't re-install it using the installer from the matplotlib website, because "Python 2.7 was not found in registry"...so...I tried to install it using `pip`, and it turns out that pip has trouble building ft2font.cpp. Alright, well, I tried to completely uninstall python(x,y). I then used the [Python windows installer](http://stackoverflow.com/questions/24251102/from-matplotlib-import-ft2font-importerror-dll-load-failed-the-specified-pro) in an attempt to repair things. No luck. – bzm3r Jun 17 '14 at 19:33
  • I then uninstalled everything, and manually deleted as much as I could from the registry, and from the C:\ drive (where I install Python). I try reinstalling everything. Still the same problem -- matplotlib installer says there is no Python 2.7 installed, and `pip` has the same issue. I try to use the registry patches provided [here](http://stackoverflow.com/questions/3652625/installing-setuptools-on-64-bit-windows/9131949#9131949), in an attempt to fix the registry...*but the matplotlib installer still says I don't have Python 2.7 installed*... – bzm3r Jun 17 '14 at 19:35
  • I am pretty dejected, and not sure what I should do. My problems really started when I tried out Enthought Canopy (I got an academic license). I didn't like it much, so I uninstalled it, but...nothing has been right since. I tried to delete all the Enthought registry keys as well after uninstall, so I feel that things should be clean.. – bzm3r Jun 17 '14 at 19:37
  • Going to try installing Anaconda...wish me luck! – bzm3r Jun 17 '14 at 19:50
  • Ok, as it seems something is weird with your python installation. What does happen (give version and 32/64 bits) when you type `python` on your command line (or `C:\Python27\python` if it is not on the path)? – nepix32 Jun 17 '14 at 20:06
  • Well, now I have Anaconda installed. When I type in `python`, I get: `Python 2.7.7 |Anaconda 2.0.1 (32-bit)| (default, Jun 11 2014, 10:41:43) [MSC v.1500 32 bit (Intel)] on win32`. – bzm3r Jun 17 '14 at 20:48
  • Interestingly, I can now also import matplotlib. However, the matplotlib installer still believes Python is not installed anywhere. – bzm3r Jun 17 '14 at 20:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/55798/discussion-between-nepix32-and-user89). – nepix32 Jun 17 '14 at 21:28
2

I am running windows 7 with Python version 3.7.1 and Pip version 19.1.1

I needed to install Microsoft visual studio. Microsoft visual studio is needed for the kiwisolver that is installed with matplotlib using pip. It is free but a 4MB download took over one to two hours to get on my machine and installed.

After using pip to install matplotlib, but without visual studio on my machine, running my script with

import matplotlib.pyplot as plt

the error I had was:

import matplotlib ImportError: DLL load failed: The specified procedure could not be found

After installing visual studio everything worked great!

Get Microsoft visual studio here.

trotta
  • 1,232
  • 1
  • 16
  • 23
P_freak
  • 21
  • 2
2

None of above solutions worked for me! Try this:

pip uninstall matplotlib
pip install -U matplotlib==3.2.0rc1
Tabaraei
  • 445
  • 2
  • 7
  • 18
1

If you are getting error each time u try installing matplotlib on ur pc through jupyter, just down download the ccleaner and then click on the health check icon after installation, followed by the custom clean to check for duplicated files causing the issue, then go back to install the matplotlib through anaconda command prompt by typing pip install matplotlib

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
PETER
  • 11
  • 1
0

to me i solved the problem by uninstalling python 3.8 and installed python 3.5

mostafa adel
  • 11
  • 1
  • 2
0

just install "Microsoft Visual C++ redistributable"

Phonix
  • 2,010
  • 18
  • 27