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
Definitive docs for how to compile on Windows #1717
I've managed to compile matplotlib under Windows 7, but it was a bit of a fight and I felt like a kludged one too many things. I've not been able to find a guide for building matplotlib on Windows, except for a smattering of newsgroup posts a long time ago (http://sourceforge.net/mailarchive/message.php?msg_id=27961105)
Really this info needs to be on the website before it becomes a lost art; apparently someone is doing it (Christophe probably?) because the Windows binary releases continue to show up ;)
As you say, @cgohlke is probably the best person for this. @dhyams - did you write up what you did so that it might reduce the total work that is needed to complete this issue?
No, I've not written anything up yet; I will do so as soon as I have the chance. I'm afraid that half of it is going to be bad practice though, and possibly a little embarrassing to me ;)
TBH I have tried in the past to build on Windows, and failed pretty miserably - I find that more embarrassing - and you never know, you might learn something! 😄
Thanks mdboom. In my guide, I made it a priority not to "cheat" and use cgohlke premade library binaries. Not that I think he cheated (obviously!), but part of the gist of my raising this issue was to enable everyone to build, even if something were to happen to whomever is building the windows binaries (cgholke I presume).
@cgohlke: You mention in your guide that this isn't the procedure you use to build the distribution binaries...so what's different? It is something trivial, or something important that others might need to know? Especially on Windows, the smallest detail can really throw a monkey wrench into things...
It seems that some of my comments were not taken well; that was not my intention. This issue report was born from my own struggles in getting matplotlib compiled under Windows, searching on the website and through newsgroups for the "right" way to do it, and not finding anything.
I never meant to imply that only one person had ever built on Windows. I put the word "definitive" in the title of this issue, because there's no telling what hacks or shortcuts were taken by these others; I know, because I'm one of the "others". Maybe they did it right, maybe not...but no one ever wrote it down until now.
I didn't want to use matplotlib-1.x-windows-link-libraries.zip because I figured that most people (including me) would have a distaste for downloading binaries from someone's personal website; I know that I can trust you, but the average person I would think (if they are prudent at all) would have serious pause. I looked at the existence of the link-libraries.zip as a convenience for the "quick and dirty" build, but not something that should be part of any official build instructions.
As it stands, I've wasted an entire evening and greater part of a Saturday morning putting together instructions that are bad (I didn't know that the GnuWin32 binaries were outdated, but after investigating, they certainly are), and have apparently rubbed one of the main devs the wrong way. So I'll bow out of this discussion, and the Powers That Be can decide what to do with the info enclosed herein.
@dhyams: I applaud you for taking the initiative on this. I, too, even as the lead developer of matplotlib, have found it hard to piece together current information about building on Windows -- it's been on my TODO list for a long time to document it well, but, like you, found it hard to piece together best practices from all of the available options -- so I was really pleased to see someone take this on. I'm hoping that some confluence of your work and the new information from @cgohlke can find its way into the official docs and be maintained.
I took the liberty of lifting cgohlke's scripts from this page to a new repository (https://github.com/jbmohler/matplotlib-winbuild). I had to update a few of the versions for the dependencies. I'd welcome pull requests if other people want to improve those scripts.
Thanks @jbmohler. I think this issue has gone stale, partly as I don't believe there is a tangible outcome in the description. The contents of this issue are here for posterity, but I suggest we go ahead and close this issue. @mdboom?
Apologies for this going stale. I'd still like to see some of this information moved into the docs proper (or at least a link to some good canonical resource), and we have a good start for that here.
BTW, I have had good luck using @cgohlke batch script to build the dependencies for python 2.7.
Most of us building probably only want to build for 1 version of python and already have python installed with python.exe on our PATH
If you meet that criteria and are using python 2.7 only (I think this will count for the majority still?), you will need to make these edits to the batch file:
replace py -3 with python
and replace
echo import sys, os, urllib.parse, urllib.request > fetch.py
echo name = urllib.parse.urlsplit(sys.argv[1])[2].split('/')[-1] >> fetch.py
echo if not os.path.exists(name): >> fetch.py
echo print("Fetching", sys.argv[1]) >> fetch.py
echo content = urllib.request.urlopen(sys.argv[1]).read() >> fetch.py
echo with open(name, 'wb') as fd: >> fetch.py
echo fd.write(content) >> fetch.py
with
echo import sys, os, urllib, urlparse > fetch.py
echo name = urlparse.urlsplit(sys.argv[1])[2].split('/')[-1] >> fetch.py
echo if not os.path.exists(name): >> fetch.py
echo print("Fetching", sys.argv[1]) >> fetch.py
echo content = urllib.urlopen(sys.argv[1]).read() >> fetch.py
echo with open(name, 'wb') as fd: >> fetch.py
echo fd.write(content) >> fetch.py
Also, the file assumes that nmake is on your system PATH. I don't think this is usually the case when installing the windows SDK? At least not on my machine...
In this case, you need to use the SET command at the top to set the path to nmake, which is usually something like:
This is usually something like C:\program files (x86)\Microsoft Visual Studio 12.0\VC\bin\nmake.exe
then replace all calls to nmake with %NMAKE%
You are also going to want to remove the sections of the script where there are irrelevant builds.
I.E I only wanted to build for python 27, 64 bit, so I only kept the 'build' section that began with: rem Build for VC 2008 64 bit
The URL for the zlib download also needs updating (best to always check the URLS).
@jbmohler@Tillsten Can one or both of you work on this? I see that the long set of directions from @cgohlke is for 1.2 and might be out of date. I don't have the expertise to sort that out.
Could you also add the links to @jbmohler 's build scripts discussed in #3388.
Thank you for providing the matplotlib. Now I 'm working on a small research project with Python 2.7 and installed Microsoft VS 2012 on my laptop. And this make me unable to run python matplotlib-winbuild\buildall.py. Do you have other alternatives to solve this?
Firstly, this bug was closed almost two years ago, and secondly, it is only a change in documentation. Please open a new issue with a full description of the problem. Comments on really old issues are just going to get lost.
@WJTey I think your question might better be directed to the matplotlib-users@python.org or other mailing list; it is a "how do I manage MS compilers for compiling python extensions" question, not a matplotlib issue.
If you want to build c-extensions from windows, you can not use VS2012 (it must be VS2008 for compatibility reasons). It seems that https://www.microsoft.com/en-us/download/details.aspx?id=44266 is now the recommended compiler to use for python 2.7 extensions on windows.
If you go to python 3.5+ building on windows is decoupled from an exact version of VS and will be much easier to maintain going forward.
"If you go to python 3.5+ building on windows is decoupled from an exact version of VS and will be much easier to maintain going forward."
How I wish that were true.
This build is still kind of a kludge - doesn't seem to want to build well, and there's a lot of needing of specific versions/instructions missing. The only reasons I'm sticking with this, is that I want to update/increase my knowledge of the C++/C and python build systems...
Otherwise I'd say the build is garbage, on windows anyways.
Mismatched C RT libraries
Hard-coded dependence on msvc 2010
Mysterious segfaults
Contradictory build instructions
Undocumented dependencies on empty files being present in the filesystem
Activity
pelson commentedon Feb 4, 2013
As you say, @cgohlke is probably the best person for this. @dhyams - did you write up what you did so that it might reduce the total work that is needed to complete this issue?
Cheers,
dhyams commentedon Feb 7, 2013
No, I've not written anything up yet; I will do so as soon as I have the chance. I'm afraid that half of it is going to be bad practice though, and possibly a little embarrassing to me ;)
pelson commentedon Feb 7, 2013
TBH I have tried in the past to build on Windows, and failed pretty miserably - I find that more embarrassing - and you never know, you might learn something! 😄
dhyams commentedon Feb 9, 2013
OK, here's something get the ball rolling. Comments welcome....this took a lot longer than I anticipated...dang windows ;)
https://www.dropbox.com/s/vdslb2mt1dju8ao/matplotlib_compile_win32_v1.html
https://www.dropbox.com/s/csusx7ykgtd0yom/How%20to%20compile%20Matplotlib%20under%20Windows.docx
mdboom commentedon Feb 11, 2013
Haven't had a chance to try these out yet, but just wanted to say thanks to all for working on this. This is very good stuff to have!
dhyams commentedon Feb 11, 2013
Thanks mdboom. In my guide, I made it a priority not to "cheat" and use cgohlke premade library binaries. Not that I think he cheated (obviously!), but part of the gist of my raising this issue was to enable everyone to build, even if something were to happen to whomever is building the windows binaries (cgholke I presume).
@cgohlke: You mention in your guide that this isn't the procedure you use to build the distribution binaries...so what's different? It is something trivial, or something important that others might need to know? Especially on Windows, the smallest detail can really throw a monkey wrench into things...
dhyams commentedon Feb 11, 2013
It seems that some of my comments were not taken well; that was not my intention. This issue report was born from my own struggles in getting matplotlib compiled under Windows, searching on the website and through newsgroups for the "right" way to do it, and not finding anything.
I never meant to imply that only one person had ever built on Windows. I put the word "definitive" in the title of this issue, because there's no telling what hacks or shortcuts were taken by these others; I know, because I'm one of the "others". Maybe they did it right, maybe not...but no one ever wrote it down until now.
I didn't want to use matplotlib-1.x-windows-link-libraries.zip because I figured that most people (including me) would have a distaste for downloading binaries from someone's personal website; I know that I can trust you, but the average person I would think (if they are prudent at all) would have serious pause. I looked at the existence of the link-libraries.zip as a convenience for the "quick and dirty" build, but not something that should be part of any official build instructions.
As it stands, I've wasted an entire evening and greater part of a Saturday morning putting together instructions that are bad (I didn't know that the GnuWin32 binaries were outdated, but after investigating, they certainly are), and have apparently rubbed one of the main devs the wrong way. So I'll bow out of this discussion, and the Powers That Be can decide what to do with the info enclosed herein.
pelson commentedon Feb 12, 2013
There is room for everybody here - if we all agreed all of the time we would have a problem! 😄
mdboom commentedon Feb 12, 2013
@dhyams: I applaud you for taking the initiative on this. I, too, even as the lead developer of matplotlib, have found it hard to piece together current information about building on Windows -- it's been on my TODO list for a long time to document it well, but, like you, found it hard to piece together best practices from all of the available options -- so I was really pleased to see someone take this on. I'm hoping that some confluence of your work and the new information from @cgohlke can find its way into the official docs and be maintained.
cgohlke scripts as in matplotlib/matplotlib#1717
jbmohler commentedon Dec 5, 2013
I took the liberty of lifting cgohlke's scripts from this page to a new repository (https://github.com/jbmohler/matplotlib-winbuild). I had to update a few of the versions for the dependencies. I'd welcome pull requests if other people want to improve those scripts.
pelson commentedon Dec 9, 2013
Thanks @jbmohler. I think this issue has gone stale, partly as I don't believe there is a tangible outcome in the description. The contents of this issue are here for posterity, but I suggest we go ahead and close this issue. @mdboom?
mdboom commentedon Dec 10, 2013
Apologies for this going stale. I'd still like to see some of this information moved into the docs proper (or at least a link to some good canonical resource), and we have a good start for that here.
JamesRamm commentedon Jul 25, 2014
BTW, I have had good luck using @cgohlke batch script to build the dependencies for python 2.7.
Most of us building probably only want to build for 1 version of python and already have python installed with python.exe on our PATH
If you meet that criteria and are using python 2.7 only (I think this will count for the majority still?), you will need to make these edits to the batch file:
replace
py -3withpythonand replace
with
Also, the file assumes that
nmakeis on your system PATH. I don't think this is usually the case when installing the windows SDK? At least not on my machine...In this case, you need to use the SET command at the top to set the path to nmake, which is usually something like:
This is usually something like
C:\program files (x86)\Microsoft Visual Studio 12.0\VC\bin\nmake.exethen replace all calls to
nmakewith %NMAKE%You are also going to want to remove the sections of the script where there are irrelevant builds.
I.E I only wanted to build for python 27, 64 bit, so I only kept the 'build' section that began with:
rem Build for VC 2008 64 bitThe URL for the zlib download also needs updating (best to always check the URLS).
cgohlke commentedon Jul 26, 2014
Calling
SetEnv.Cmdtakes care of that.1 remaining item
tacaswell commentedon Aug 17, 2014
If the text if this issue is not in the docs, it should be.
tacaswell commentedon Aug 22, 2014
@jbmohler @Tillsten Can one or both of you work on this? I see that the long set of directions from @cgohlke is for 1.2 and might be out of date. I don't have the expertise to sort that out.
Could you also add the links to @jbmohler 's build scripts discussed in #3388.
This should go in the tree near https://tacaswell.github.io/matplotlib/users/installing.html
I have labeled this as not-a-blocker as it should be done, but I intend to tag 1.4.0 this weekend with or with out it.
jbmohler commentedon Aug 22, 2014
I am working on a PR with the documentation to point to my build scripts & also get an e-mail out to -dev offering that repo.
tacaswell commentedon Aug 22, 2014
@jbmohler Please be aware of #3397 so we don't cause massive impossible to merge prose conflicts.
tacaswell commentedon Aug 24, 2014
closed by #3401
WJTey commentedon Jul 18, 2016
Thank you for providing the matplotlib. Now I 'm working on a small research project with Python 2.7 and installed Microsoft VS 2012 on my laptop. And this make me unable to run python matplotlib-winbuild\buildall.py. Do you have other alternatives to solve this?
QuLogic commentedon Jul 19, 2016
Firstly, this bug was closed almost two years ago, and secondly, it is only a change in documentation. Please open a new issue with a full description of the problem. Comments on really old issues are just going to get lost.
efiring commentedon Jul 19, 2016
@WJTey I think your question might better be directed to the matplotlib-users@python.org or other mailing list; it is a "how do I manage MS compilers for compiling python extensions" question, not a matplotlib issue.
tacaswell commentedon Jul 19, 2016
If you want to build c-extensions from windows, you can not use VS2012 (it must be VS2008 for compatibility reasons). It seems that https://www.microsoft.com/en-us/download/details.aspx?id=44266 is now the recommended compiler to use for python 2.7 extensions on windows.
If you go to python 3.5+ building on windows is decoupled from an exact version of VS and will be much easier to maintain going forward.
smaudet commentedon Nov 5, 2016
"If you go to python 3.5+ building on windows is decoupled from an exact version of VS and will be much easier to maintain going forward."
How I wish that were true.
This build is still kind of a kludge - doesn't seem to want to build well, and there's a lot of needing of specific versions/instructions missing. The only reasons I'm sticking with this, is that I want to update/increase my knowledge of the C++/C and python build systems...
Otherwise I'd say the build is garbage, on windows anyways.
smaudet commentedon Nov 6, 2016
Frightful problems I have encountered:
Mismatched C RT libraries
Hard-coded dependence on msvc 2010
Mysterious segfaults
Contradictory build instructions
Undocumented dependencies on empty files being present in the filesystem