Xcode-provided python uses the wrong libdir
Author: madsmtmCreated Sep 14, 2026Updated Sep 15, 2026
Bug Description
When using the system python3 (which forwards to the one by Xcode), this line:
https://github.com/PyO3/pyo3/blob/da9da49e771be99d1de229c9b406c4e91cca8a9a/pyo3-build-config/src/impl_.rs#L474
Prints /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib, even when Xcode is installed in a different location, such as /Applications/Xcode_2.app/Contents/Developer/usr/bin/python3.
I suspect a similar problem happens for Command Line Tools.
Steps to Reproduce
- Have Xcode installed (and probably only that, not homebrew or a uv-managed python)
mv /Applications/Xcode.app /Applications/Xcode_2.app- Do either
sudo xcode-select --switch /Applications/Xcode_2.apporexport DEVELOPER_DIR=/Applications/Xcode_2.app/Contents/Developer cargo buildnow fails.
I get the following linker errors:
warning: search path '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib' not found
library 'python3.9' not foundYour operating system and version
macOS 15.7.9
Your Python version (python --version)
Python 3.9.6
Your Rust version (rustc --version)
rustc 1.98.1 (48a229cea 2026-09-01)
Your PyO3 version
0.29.2
How did you install python? Did you use a virtualenv?
Xcode
Additional Info
No response
Source: PyO3/pyo3