Matplotlib costruire Problema: Errore C1083: Impossibile aprire il file di inclusione: 'ft2build.h'
-
11-09-2019 - |
Domanda
ft2build.h si trova qui:
C: \ Program Files \ GnuWin32 \ include
Inizialmente, ho fatto lo stesso errore come in questo caso:
ma da allora, ho corretto quel particolare errore (ho aggiunto la directory sopra alla lista "include", piuttosto che la lista "eseguibili"), ma ho ancora un errore. L'uscita completa è questa:
BUILDING MATPLOTLIB
matplotlib: 0.98.5.2
python: 2.6.2 Stackless 3.1b3 060516 (release26-maint, Apr
14 2009, 21:19:36) [MSC v.1500 32 bit (Intel)]
platform: win32
Windows version: (5, 1, 2600, 2, 'Service Pack 3')
REQUIRED DEPENDENCIES
numpy: 1.3.0
freetype2: found, but unknown version (no pkg-config)
* WARNING: Could not find 'freetype2' headers in any
* of '.', '.\freetype2'.
OPTIONAL BACKEND DEPENDENCIES
libpng: found, but unknown version (no pkg-config)
* Could not find 'libpng' headers in any of '.'
Tkinter: no
* No tk/win32 support for this python version yet
wxPython: 2.8.9.2
* WxAgg extension not required for wxPython >= 2.8
Gtk+: no
* Building for Gtk+ requires pygtk; you must be able
* to "import gtk" in your build/install environment
Mac OS X native: no
Qt: no
Qt4: no
Cairo: no
OPTIONAL DATE/TIMEZONE DEPENDENCIES
datetime: present, version unknown
dateutil: matplotlib will provide
pytz: matplotlib will provide
OPTIONAL USETEX DEPENDENCIES
dvipng: no
ghostscript: no
latex: no
pdftops: no
[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.projections', 'mpl_to
olkits', 'matplotlib.numerix', 'matplotlib.numerix.mlab', 'matplotlib.numerix.ma
', 'matplotlib.numerix.npyma', 'matplotlib.numerix.linear_algebra', 'matplotlib.
numerix.random_array', 'matplotlib.numerix.fft', 'matplotlib.delaunay', 'pytz',
'dateutil', 'dateutil/zoneinfo']
running build
running build_py
copying lib\matplotlib\mpl-data\matplotlibrc -> build\lib.win32-2.6\matplotlib\m
pl-data
copying lib\matplotlib\mpl-data\matplotlib.conf -> build\lib.win32-2.6\matplotli
b\mpl-data
running build_ext
building 'matplotlib.ft2font' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG -IC:\Python26\lib\site-packages\numpy\core\include -I. -IC:\Pyth
on26\lib\site-packages\numpy\core\include\freetype2 -I.\freetype2 -IC:\Python26\
include -IC:\Python26\include\Stackless -IC:\Python26\PC /Tpsrc/ft2font.cpp /Fob
uild\temp.win32-2.6\Release\src/ft2font.obj
ft2font.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C
4530: C++ exception handler used, but unwind semantics are not enabled. Specify
/EHsc
c:\python26\lib\site-packages\matplotlib-0.98.5.2\src\ft2font.h(13) : fatal erro
r C1083: Cannot open include file: 'ft2build.h': No such file or directory
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' fa
iled with exit status 2
Devo dire che questo è Python 2.6
Soluzione
È stato installato freetype correttamente? Se si dispone, ci dovrebbe essere un file chiamato ft2build.h
qualche parte sotto la directory di installazione e la directory in cui si trova il file è quello che si dovrebbe specificare con -I
. La stringa "GnuWin32" non appare in qualsiasi parte del output del comando build, così sembra che non hai messo quella directory nel corretto includere nell'elenco.
Altri suggerimenti
Questo errore avviene quando si costruisce matplotlib su Ubuntu 10.10 anche. La soluzione è quella di fare:
sudo apt-get install python-dev libfreetype6-dev
Un'altra soluzione per Mac OS X è quello di installare Freetype con Homebrew.
brew install freetype
Per coloro che potrebbero avere lo stesso problema, ma su un Mac OS 10.6 (Snow Leopard) e Python 2.7. , La soluzione più semplice che ho trovato è stato quello di ottenere un make file che scarica Numpy, SciPy e matplotlib e compilarli per voi. È possibile personalizzare il file make di farti matplotlib solo. Ecco il link href="http://stefan.sofa-rockers.org/2010/11/17/building-numpy-scipy-matplotlib-python-27-snow-leo/" rel="nofollow"> alla soluzione.
Ho avuto lo stesso errore nel cappello rosso 6. Risulta che avevo bisogno di installare freetype-devel
, non freetype
(utilizzando sudo yum install freetype-devel
)
Ho anche risolto il problema installando freetype utilizzando homebrew su Mac OS X. Tuttavia, ciò non è stato sufficiente, come le librerie non sono state collegate correttamente in Mac OS X 10.7. Così ho dovuto aggiungere manualmente loro di pip
comando come segue:
brew install freetype
brew install libpng
LDFLAGS="-L/usr/local/opt/freetype/lib -L/usr/local/opt/libpng/lib" CPPFLAGS="-I/usr/local/opt/freetype/include -I/usr/local/opt/libpng/include -I/usr/local/opt/freetype/include/freetype2" pip install matplotlib
Si noti che si deve anche aggiungere il /usr/local/opt/freetype/include/freetype2
cartella, che non è incluso di default sulla notifica homebrew, ma si tradurrà in non trovare ft2build.h
.
Sono stato in grado di risolvere questo su Windows nel modo seguente:
set INCLUDE=%INCLUDE%;C:\tmp\msvcr90-x32
set LIB=%LIB%;C:\tmp\msvcr90-x32
pip.exe install matplotlib
Le librerie di collegamento per Freetype per Windows possono essere trovate qui: http: // www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib (dal commento di meawoppl)
Basta scaricare il "matplotlib-1.x-windows-link-libraries.zip", e aprire il file README dalla chiusura lampo.
Scarica il file in una cartella sul disco C.
In finestre CMD chiederà come amministratore a navigare nel percorso utilizzando
cd..
o cd wheels
(nel mio caso ho salvato il file da c:\Wheels
)
poi tipo pip install YourFilename.whl
I risultati in
Processing c:\wheels\scipy-0.19.0-cp27-cp27m-win_amd64.whl
Requirement already satisfied: numpy>=1.8.2 in c:\python27\lib\site-packages (from scipy==0.19.0)
Installing collected packages: scipy
Successfully installed scipy-0.19.0