6

I'm using Anaconda 5.0.1 with Python 2.7.14. When I open a jupyter notebook and try to run the following:

%matplotlib inline

I get the following error:

ImportError                               Traceback (most recent call last)
C:\toolkits.win\anaconda2\envs\dlc\lib\site-packages\matplotlib\font_manager.py in <module>()
     56 
     57 import matplotlib
---> 58 from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir
     59 from matplotlib.compat import subprocess
     60 from matplotlib.fontconfig_pattern import (

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

When I try to drill into the error, the problem is with ft2font:

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

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

I double-checked and made sure freetype is installed:

(dlc) C:\Users\Larry>conda install freetype
Fetching package metadata .............
Solving package specifications: .

# All requested packages already installed.
# packages in environment at C:\toolkits.win\anaconda2\envs\dlc:
#
freetype                  2.8               vc9hf582001_0  [vc9]

Any ideas?

french bread
  • 73
  • 1
  • 1
  • 5
  • Possible duplicate of [from matplotlib import ft2font: "ImportError: DLL load failed: The specified procedure could not be found."](https://stackoverflow.com/questions/24251102/from-matplotlib-import-ft2font-importerror-dll-load-failed-the-specified-pro) – zimmerrol Nov 05 '17 at 21:17
  • 2
    That question is more than three years out of date and doesn't really offer a solution. I've already tried uninstalling both matplotlib and freetype and neither solved the problem. – french bread Nov 06 '17 at 02:33

8 Answers8

6

Improving a bit on the above suggestion:

pip install matplotlib --force-reinstall
6
conda install freetype --force-reinstall
S Dilwali
  • 71
  • 1
  • 2
2

def _check_versions():

# Quickfix to ensure Microsoft Visual C++ redistributable
# DLLs are loaded before importing kiwisolver
from . import ft2font

Try install Microsoft Visual C++ redistributable

Alex
  • 21
  • 1
2

I found that if conda doesn't activate when the terminal starts up properly, you get this error.

I found that by opening the terminal, typing a bunch of stuff and pressing enter a a lot to prevent conda from activating and then when I tried to run a matplotlib inclusive script it would give me this error, but when I let it start without interference, it would not give me this error (it would run fine, at least past this error).

Considering this, it may be useful to keep import matplotlib at the top of the file if possible, so you don't wait a while and then find out that matplotlib won't load.

JVE999
  • 3,327
  • 10
  • 54
  • 89
  • the OP problem happened to me because I did not start Miniconda prompt with admin privileges. I needed to reinstall Miniconda and then download the libraries again (with admin privileges) and everything worked great. – bardulia Jul 01 '23 at 10:22
1

Debugged into same issue. It seems another access-deny issue.

Solution: Re-install matplotlib in elevated mode.

  1. Launch Anaconda Prompt as Administrator
  2. Run conda install matplotlib
  3. Finish installing any required packages.
clinomaniac
  • 2,200
  • 2
  • 17
  • 22
Shu
  • 11
  • 1
  • correct! this problem happened to me because I was importing some libraries in Miniconda but I forgot previously to open Miniconda prompt with admin rights which causes some issues writing some matplotlib files. After reinstalling Miniconda and using admin rights everything works fine. – bardulia Jul 01 '23 at 10:20
1

My solution: unstall matplotlib, and re-install it with pip.

kxiaocai
  • 2,803
  • 1
  • 12
  • 8
1

I have the same issue and on my machine the problem was that Java (openJDK) was mentioned in the PATH-variable prior to Python (Anaconda in my case).

If you open a cmd and type

echo %PATH%

you can check if that is the case on your machine as well. If it states ...\Java\openJDK<version>\bin is before the Anaconda directories, the wrong freetype.dll library is getting found and the error occurs.

All you have to do is to change PATH to state the anaconda directories before the Java directories. This may raise another set of issues with Java though...

leviathan
  • 363
  • 3
  • 10
1

I solved this problem by installing the last Microsoft Visual C++ redistributable 2019. In my case : python 3.8.7 matplotlib : 20.3.3 test.py result in IDLE

  • Installing MS Visual C++ redistributable 2019 solved my issue too. I needed this for PowerBI visuals created with Python. – ccasimiro9444 Jan 12 '21 at 23:29