-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Can't find pybind11 headers when building from source #29741
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
Without build isolation in pip, you need to install build dependencies before Matplotlib. The For now, you should install the build dependencies first (you can use |
Even if I go through conda, and I have |
I suspect this might be because |
I tried installing a c and cxx compiler into the conda environment (as should now happen anyway after #28352), and it didn't help. I'm still getting errors finding
|
This doesn't look right. Do you have the wrong |
Ah, thanks - I have no idea why that's where the build is trying to find the pybind11 headers, perhaps because I installed and uninstalled it in the past using |
I tracked this issue down. It happens when e.g. no pybind11 is installed globally but pybind11 is installed locally in user's home directly. Global install can be done with The reason is the following.
I'd say the cause is at pybind11-config. Meson and matplotlib just invoke it. Temporary workaround is of course to install globally. |
A entry point has the correct executable burned into it. There is a long standing bug in pip, which actually fakes isolated environments, but it causes things that are supposed to work (like this) to break. Have you tried uv, which doesn't have this bug, since it uses real virtual environments for isolated environments? |
Blaming pip won't help the users, but do you know of a existing bug report to pip with relevant discussion? |
If blaming pip causes them to switch to uv, then yes it will. :) And it's not helpful to blame other packages if it's pip's fault. There are lots of issues on this, but pypa/pip#13222 is pretty good. Everyone knows it's a problem, and no one wants to completely redesign the isolation internals to follow modern standards and be rewarded with a small slowdown. I've tried to workaround this pip bug, but it's terrible. You can see some discussion in scikit-build/scikit-build-core#993, and my failed attempt to work around it in scikit-build/cmake-python-distributions#605 (I'd need to write a shim binary for Windows, it seems). I believe this issue describes two problems; the one at the beginning was related to not installing pybind11 and then picking it up without build isolation, and the later one is the build isolation bug listed above. Could be wrong though. |
Actually are you sure that's the same bug? In pypa/pip#13222 it says "Install with flag --no-build-isolation." gives no bug, but in the reproduction issue in pybind/pybind11#5631 I already include that flag. |
Ahh, that's a third one, a |
Not sure. Anyway what's the difference between making a single global virtualenv per user with |
Bug summary
On macOS I am failing to build Matplotlib from source, because the c++ compiler cannot find Pybind11 headers. I've followed instructions at https://matplotlib.org/devdocs/devel/development_setup.html, and I get the same issue in a virtual environment, a virtual environment managed with
uv
, and aconda
environment.I have pybind11 installed globally (using
brew
), and in the Python virtual environment:Code for reproduction
Actual outcome
Expected outcome
A working install
Additional information
No response
Operating system
macOS
Matplotlib Version
Latest
main
branchMatplotlib Backend
No response
Python version
Python 3.12.8
Jupyter version
No response
Installation
git checkout
The text was updated successfully, but these errors were encountered: