-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: matplotlib (kiwisolver) interference with other package #28991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How did you install opensim? It does not look like it is on pypi and their docs reccomend using conda (https://opensimconfluence.atlassian.net/wiki/spaces/OpenSim/pages/53085346/Scripting+in+Python). While wheels mostly work, there are some technical and inter-project coordination issues where they will fail with extension modules (see https://pypackaging-native.github.io for more details). In the short term I suggest sticking with conda or pixi (https://pixi.sh/latest/) for creating your environments and steer clear of wheels. My suspicion is that both libraries are built against and bundle different versions of a shared dependency (which wheels require us to do), likely the c++ runtime, with the condition that the code built against the older version can run with the newer version of the library, but code built against the newer version can not run with the older. Based on the order that works, I think this means that mpl is built with the older version and opensim is built with the newer version. I suspect that this is a relative of #28551 In the future, please always copy-paste error messages rather than screen shots. Text is much easier to deal with and while not super relevant here, if someone wants to try to reproduce |
Have you opened an issue with Opensim? It is their library that can't load. |
Thanks @tacaswell and @jklymak for your responses.
OpenSim actually works well, even if I import it after numpy, scipy, or scikit-learn. But, in this specific condition the error is raised.
Sorry, I just changed the errors to text.
I built opensim-core for win64 and py3.12 using Visual Studio 17 2022. Do you think the version of MSVC is the issue? I investigated more and checked the imported modules using Any help is greatly appreciated. |
You probably need to build all the packages with c extensions the same way. Or install everything with conda/mamba if that is available. |
I see that many users have opened similar issue, but this is not matplotlib-specific. Is kiwisolver a required dependency? What are the limitations without kiwisolver? I could see that it has vey limited application in matplotlib, only here: matplotlib/lib/matplotlib/_layoutgrid.py Line 20 in 3f42f35
By any chance, would it be possible to make it optional? So, no one would ever open any issue related to DLL ImportError. |
It's used for the constrained layout manager. We don't currently have optional dependencies and I'm not sure how easy it is to make something optional. Many of our examples use constrained layout so making it optional would mean we would have to rework all of those. But I'm not very familiar with windows packaging. Is there some reason we/kiwisolver/our users cannot fix this? |
will avoid using the kiwisolver wheels and compile it from source. I suspect that will solve the problem for @mrrezaie (not using pip/wheel and using conda/mamba/pixi instead is a more general solution). I suspect (but am not 100% sure) that there is a technical path to making this work with wheels (it may require a one or more no-change "releases" to rebuild wheels), but issues stemming from packaging issues with one of the many distribution channels is not sufficient reason to make it an optional dependency. |
I do wonder if we should consider vendoring kiwisolver so if there are build problems they will be for all of Matplotlib and not just in a dependency. I also am not sure how kiwisolver feels about the added maintenance burden of supporting our very broad user base; maybe @MatthieuDartiailh has an opinion? |
Hi, thanks for your help. The I found this post (related to matplotlib and kiwisolver), and installed Microsoft Visual C++ Redistributable, it fixed the issue completely!!! Just curious, is there any integration? For example, |
kiwisolver applied the same fix we did: nucleic/kiwi@7695597 but you must be using the latest version. As this has been fixed there, I don't think we should do much else ourselves. |
I am fine with doing whatever update help streamline the process as I did following the suggestion from @QuLogic. Side note, as a user of matplotlib I very much enjoy the constraints based layout and wished it was the default so I am happy to help make kiwi integration easier. |
Thanks @MatthieuDartiailh awesome - as long as we aren't imposing on you we are more than happy to not vendor Kiwisolver. Just wanted to make sure it wasn't an unintended obligation on your part 😉 Thanks for maintaining it, as it is a very nice abstraction of some difficult concepts. |
Thanks all, please let me continue this discussion here a little bit further. Any idea why @MatthieuDartiailh Thanks. |
@mrrezaie if you are still having problems installing Kiwisolver, and you are using the latest version of kiwisolver, then perhaps the place to discuss is on the kwiwsolver issue tracker. Per the above, we think this issue was solved in the latest release. If you are not a developer, I strongly suggest using conda/mamba for installing things that require compilation, particularly for windows, particularly if there is no wheel available for opens. Then you get the benefit of folks having already done this for you (assuming you have a supported machine). |
The latest version is 1.4.7 (https://pypi.org/project/kiwisolver/) since Sep 4 and at the time of opening this issue. Anyway, thank again. |
Bug summary
Hi, I use another package (opensim), which has lots of dll and exe files, along with matplotlib. It seems that matplotlib is broking something at import.
Actual outcome
If I import matplotlib first, I receive this error:
Expected outcome
If I import opensim, followed by matplotlib, everything works well:
Operating system
Windows 11
Matplotlib Version
3.9.2
Python version
3.12.7
Installation
pip
The text was updated successfully, but these errors were encountered: