Skip to content

Definitive docs for how to compile on Windows #1717

Closed

Description

@dhyams

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 ;)

Activity

  1. pelson commented on Feb 4, 2013

    @pelson
    Member

    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,

  2. dhyams commented on Feb 7, 2013

    @dhyams
    ContributorAuthor

    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 ;)

  3. pelson commented on Feb 7, 2013

    @pelson
    Member

    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! 😄

  4. dhyams commented on Feb 9, 2013

    @dhyams
    ContributorAuthor

    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

  5. mdboom commented on Feb 11, 2013

    @mdboom
    Member

    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!

  6. dhyams commented on Feb 11, 2013

    @dhyams
    ContributorAuthor

    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...

  7. dhyams commented on Feb 11, 2013

    @dhyams
    ContributorAuthor

    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.

  8. pelson commented on Feb 12, 2013

    @pelson
    Member

    and have apparently rubbed one of the main devs the wrong way. So I'll bow out of this discussion

    There is room for everybody here - if we all agreed all of the time we would have a problem! 😄

  9. mdboom commented on Feb 12, 2013

    @mdboom
    Member

    @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.

  10. jbmohler commented on Dec 5, 2013

    @jbmohler
    Contributor

    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.

  11. pelson commented on Dec 9, 2013

    @pelson
    Member

    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?

  12. mdboom commented on Dec 10, 2013

    @mdboom
    Member

    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.

  13. JamesRamm commented on Jul 25, 2014

    @JamesRamm

    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).

  14. cgohlke commented on Jul 26, 2014

    @cgohlke
    Contributor

    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?

    Calling SetEnv.Cmd takes care of that.

  15. 1 remaining item

  16. added this to the v1.4.0 milestone on Aug 17, 2014
  17. tacaswell commented on Aug 17, 2014

    @tacaswell
    Member

    If the text if this issue is not in the docs, it should be.

  18. tacaswell commented on Aug 22, 2014

    @tacaswell
    Member

    @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.

  19. jbmohler commented on Aug 22, 2014

    @jbmohler
    Contributor

    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.

  20. tacaswell commented on Aug 22, 2014

    @tacaswell
    Member

    @jbmohler Please be aware of #3397 so we don't cause massive impossible to merge prose conflicts.

  21. tacaswell commented on Aug 24, 2014

    @tacaswell
    Member

    closed by #3401

  22. WJTey commented on Jul 18, 2016

    @WJTey

    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?

  23. QuLogic commented on Jul 19, 2016

    @QuLogic
    Member

    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.

  24. efiring commented on Jul 19, 2016

    @efiring
    Member

    @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.

  25. tacaswell commented on Jul 19, 2016

    @tacaswell
    Member

    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.

  26. smaudet commented on Nov 5, 2016

    @smaudet

    "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.

  27. smaudet commented on Nov 6, 2016

    @smaudet

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions