You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Re-opening Definitive Docs for compilation on Windows. #7418
Can you open a pull request with a better version of the documentation? I don't think any of the developers work on windows, and thus will not be able to help.
I can agree that build process on Windows is a pain, but there is not a lot of things that we can change.
Mismatched C RT libraries
I am not sure I understand what do you mean. If you are talking about inttypes.h and stdint.h it is a MSVC problem and it solves with msinttypes.
Hard-coded dependence on msvc 2010
This is partly true. MSVC version is 'hardcoded' (it selects from 2008 and 2010) only for freetype because it does not have project files for newer VSs. You can use your local freetype build by passing local_freetype arg or MPLLOCALFREETYPE environment variable.
Mysterious segfaults
I cannot say anything about this as you have not shared any info about this. And I suspect it is something wrong with your setup.
Contradictory build instructions
You can help improving it.
I can suggest you next things:
Install Windows SDK
Install Miniconda and create a new environment
Install numpy python-dateutil pyparsing pytz cycler libpng zlib freetype msinttypes (for 2.7 you also need functools32) packages into it
Set MPLLOCALFREETYPE env variable and run build_alllocal.cmd
Undocumented dependencies on empty files being present in the filesystem
Thanks. According to the linked page, one would need version 14.0 for python 3.6. This translates into Visual Studio 2015. Yet on the page it links to, there are only the Build Tools for Visual Studio 2017 available. This uses version 14.13.26128. Using it, there is the error
fatal error C1047: The file ".\lib\png.lib" has been created with an older compiler.
Complete error message
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>build_alllocal.cmd
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>set TARGET=bdist_wheel
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>IF [] == [] (echo Using default target: bdist_wheel ) else (
set TARGET=
echo Using user supplied target: bdist_wheel
)
Using default target: bdist_wheel
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>IF NOT DEFINED CONDA_PREFIX (
echo No Conda env activated: you need to create a conda env with the right packages and activate it!
GOTO:eof
)
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>set LIBRARY_LIB=D:\Programme\Entwicklung\Miniconda3\envs\myenv\Library\lib
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>mkdir lib || cmd /c "exit /b 0"
Ein Unterverzeichnis oder eine Datei mit dem Namen "lib" existiert bereits.
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>copy D:\Programme\Entwicklung\Miniconda3\envs\myenv\Library\lib\zlibstatic.lib lib\z.li
b
1 Datei(en) kopiert.
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>copy D:\Programme\Entwicklung\Miniconda3\envs\myenv\Library\lib\libpng_static.lib lib\p
ng.lib
1 Datei(en) kopiert.
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>set MPLBASEDIRLIST=D:\Programme\Entwicklung\Miniconda3\envs\myenv\Library\;.
(myenv) D:\Data\Computer\Entwicklung\python\matplotlib\source\matplotlib>python setup.py bdist_wheel
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [2.2.0+622.g5e52ce11a]
python: yes [3.6.4 |Anaconda, Inc.| (default, Mar 12 2018,
20:20:50) [MSC v.1900 64 bit (AMD64)]]
platform: yes [win32]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.14.2]
install_requires: yes [handled by setuptools]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: yes [Using unknown version found on system.]
png: yes [Using unknown version found on system.]
qhull: yes [pkg-config information for 'libqhull' could not
be found. Using local copy.]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: no [skipping due to configuration]
toolkits_tests: no [skipping due to configuration]
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt5agg: yes [installing, Qt: 5.6.2, PyQt: 5.6; PySide2 not
found]
qt4agg: no [PySide not found; PyQt4 not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires cairocffi or pycairo to be installed.]
tkagg: yes [installing; run-time loading from Python Tcl /
Tk]
wxagg: no [requires wxPython]
agg: yes [installing]
cairo: no [cairocffi or pycairo not found]
windowing: yes [installing]
OPTIONAL PACKAGE DATA
dlls: no [skipping due to configuration]
running bdist_wheel
running build
running build_py
UPDATING build\lib.win-amd64-3.6\matplotlib\_version.py
set build\lib.win-amd64-3.6\matplotlib\_version.py to '2.2.0+622.g5e52ce11a'
running build_ext
building 'matplotlib._png' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPY_ARRAY_U
NIQUE_SYMBOL=MPL_matplotlib__png_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -ID:\Programme\Entwicklung\Miniconda3\envs\myenv
\lib\site-packages\numpy\core\include -ID:\Programme\Entwicklung\Miniconda3\envs\myenv\Library\include -I. -ID:\Programme\Entwicklung\Miniconda3\envs\myenv\incl
ude -ID:\Programme\Entwicklung\Miniconda3\envs\myenv\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include
" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program File
s (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10
\include\10.0.16299.0\cppwinrt" /EHsc /Tpsrc/_png.cpp /Fobuild\temp.win-amd64-3.6\Release\src/_png.obj
_png.cpp
src/_png.cpp(331): warning C4244: "Argument": Konvertierung von "Py_ssize_t" in "int", möglicher Datenverlust
src/_png.cpp(313): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_
NO_WARNINGS. See online help for details.
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: Siehe Deklaration von "sprintf"
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPY_ARRAY_U
NIQUE_SYMBOL=MPL_matplotlib__png_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -ID:\Programme\Entwicklung\Miniconda3\envs\myenv
\lib\site-packages\numpy\core\include -ID:\Programme\Entwicklung\Miniconda3\envs\myenv\Library\include -I. -ID:\Programme\Entwicklung\Miniconda3\envs\myenv\incl
ude -ID:\Programme\Entwicklung\Miniconda3\envs\myenv\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include
" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program File
s (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10
\include\10.0.16299.0\cppwinrt" /EHsc /Tpsrc/mplutils.cpp /Fobuild\temp.win-amd64-3.6\Release\src/mplutils.obj
mplutils.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:E
MBED,ID=2 /MANIFESTUAC:NO /LIBPATH:D:\Programme\Entwicklung\Miniconda3\envs\myenv\Library\lib /LIBPATH:.\lib /LIBPATH:D:\Programme\Entwicklung\Miniconda3\envs\m
yenv\libs /LIBPATH:D:\Programme\Entwicklung\Miniconda3\envs\myenv\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tool
s\MSVC\14.13.26128\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.
0.16299.0\um\x64" png.lib z.lib /EXPORT:PyInit__png build\temp.win-amd64-3.6\Release\src/_png.obj build\temp.win-amd64-3.6\Release\src/mplutils.obj /OUT:build\l
ib.win-amd64-3.6\matplotlib\_png.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\src\_png.cp36-win_amd64.lib
fatal error C1047: Die Objekt- oder Bibliotheksdatei ".\lib\png.lib" wurde mit einem älteren Compiler als andere Objekte erstellt. Erstellen Sie die alten Objek
te und Bibliotheken neu.
LINK : fatal error LNK1257: Fehler bei Codegenerierung.
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x64\\link.exe' failed with exit
status 1257
There does not seem to be a Build Tools 2015 available? Or is the problem a totally different one?
This uses version 14.13.26128. Using it, there is the error
fatal error C1047: The file ".\lib\png.lib" has been created with an older compiler.
There does not seem to be a Build Tools 2015 available? Or is the problem a totally different one?
This is know limitation of MSVC static libraries, they are 'incompatible' between 'major' releases. You are using Anaconda and static libraries build by them with MSVC 14.0, so you have to use the same compiler, or vc141 library versions, or build them yourself with MSVC 14.1.
This is getting quite old, and the landscape has changed quite a bit, even compared to the last gist posted immediately above (none of the steps regarding freetype, zlib, and libpng are necessary anymore). I'll thus close this as outdated, and we can reopen the discussion if there are specific points that need to be better documented.
Activity
[-]Re-opening Definitive Docs for compilation.[/-][+]Re-opening Definitive Docs for compilation on Windows.[/+]NelleV commentedon Nov 7, 2016
Can you open a pull request with a better version of the documentation? I don't think any of the developers work on windows, and thus will not be able to help.
tacaswell commentedon Nov 8, 2016
@Kojoley and @JanSchulz are windows developers iirc.
Have a look at what we use on appevyor which seems to build reliably.
Kojoley commentedon Nov 8, 2016
I can agree that build process on Windows is a pain, but there is not a lot of things that we can change.
I am not sure I understand what do you mean. If you are talking about
inttypes.handstdint.hit is a MSVC problem and it solves withmsinttypes.This is partly true. MSVC version is 'hardcoded' (it selects from 2008 and 2010) only for
freetypebecause it does not have project files for newer VSs. You can use your local freetype build by passinglocal_freetypearg orMPLLOCALFREETYPEenvironment variable.I cannot say anything about this as you have not shared any info about this. And I suspect it is something wrong with your setup.
You can help improving it.
I can suggest you next things:
numpy python-dateutil pyparsing pytz cycler libpng zlib freetype msinttypes(for 2.7 you also needfunctools32) packages into itMPLLOCALFREETYPEenv variable and runbuild_alllocal.cmdCan you explain?
petehuang commentedon Jan 7, 2017
@smaudet do you have any more details you can help provide so we can make things better?
ImportanceOfBeingErnest commentedon Mar 26, 2018
Would anyone be able to link to the exact compiler or suite that one has to install such that the suggested steps
would be successful?
There is a link somewhere in the docs pointing to https://www.visualstudio.com/downloads/ but that is rather unhelpful as any of those that I tried will produce some problem of png.lib not being found/compilable.
This error
suggests to use Microsoft Visual C++ 14. But how do Versions 20xx relate to version 14?
Kojoley commentedon Mar 26, 2018
@ImportanceOfBeingErnest Your best friend is this wiki page https://wiki.python.org/moin/WindowsCompilers. It has links for all the stuff you might need.
https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering
ImportanceOfBeingErnest commentedon Mar 26, 2018
Thanks. According to the linked page, one would need version 14.0 for python 3.6. This translates into Visual Studio 2015. Yet on the page it links to, there are only the Build Tools for Visual Studio 2017 available. This uses version 14.13.26128. Using it, there is the error
Complete error message
There does not seem to be a Build Tools 2015 available? Or is the problem a totally different one?
Kojoley commentedon Mar 26, 2018
True.
It looks like the link was not updates since 2017 release. Here it is https://www.visualstudio.com/vs/older-downloads/
This is know limitation of MSVC static libraries, they are 'incompatible' between 'major' releases. You are using Anaconda and static libraries build by them with MSVC 14.0, so you have to use the same compiler, or vc141 library versions, or build them yourself with MSVC 14.1.
ImportanceOfBeingErnest commentedon Mar 26, 2018
That did it. So the solution for python 3.6 (and 3.5 I suppose) is to install the
Microsoft Build Tools 2015 Update 3 which are found under
https://www.visualstudio.com/vs/older-downloads/ or more specifically under
http://download.microsoft.com/download/5/F/7/5F7ACAEB-8363-451F-9425-68A90F98B238/visualcppbuildtools_full.exe
bjoas commentedon Jul 11, 2019
I took the liberty to document how I managed to build matplotlib 3.1.1 with Visual C++ 2017, version 15.x.
https://gist.github.com/bjoas/933e8433455ac69ed3833d4ee2c6d952
Maybe this could be useful input to someone else looking to compile matplotlib and it's dependencies on Windows.
anntzer commentedon Feb 1, 2023
This is getting quite old, and the landscape has changed quite a bit, even compared to the last gist posted immediately above (none of the steps regarding freetype, zlib, and libpng are necessary anymore). I'll thus close this as outdated, and we can reopen the discussion if there are specific points that need to be better documented.