-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
CMake finding Python library and Python interpreter mismatch during pybind11 build #99
Comments
After a number of attempts trying to patch up the detection logic, I welcome external patches to fix this. |
After reading through the numerous related bug reports involving homebrew, Python, and CMake, especially Homebrew/legacy-homebrew#25118 and http://www.itk.org/Bug/view.php?id=14809 , which you have contributed to, I developed a strong headache and stopped. I especially enjoyed this four year-old quote: "Basically, CMake clings to Frameworks like a drowning sailor on OSX" from Homebrew/legacy-homebrew#10393 (comment) . The issue persists in CMake 3.5.0-rc1. For now, I can ask CMake to use the OSX system Python interpreter with |
I have some cmake logic I wrote to handle use of Anaconda python here. It is not exactly your use case, but it might give you some idea how to proceed. |
Yes,that looks useful. Supporting the default Python distribution is obviously a requirement ;) |
You might also want to investigate FindPythonLibsNew.cmake . For instance from here: https://github.com/usnistgov/REFPROP-wrappers/blob/master/cmake/FindPythonLibsNew.cmake It helped me with some of these issues. |
Encountered the same problem here. If you need to build against the non-system (Homebrew) Python install, this workaround does the trick:
|
Closing this as WONTFIX, as it's not a pybind11 issue. |
- 0b91e48 Update TravisCI: build master, but omit OS X since I still haven't figured out what goes wrong on the Travis machine, somehow the compiler flags are selected wrongly... - 697f039 TravisCI: try moving to Trusty which provides ROOT and a recent GCC - 8828506 Try to fix missing packages with preventive apt-get update - cd010ae Add additional CMake hint for ROOT package installed on Trusty platforms - ced60a6 The packaged ROOT is lacking "TPaletteAxis.h" for some reason. I'm getting a bit angry and am turning off the OnlineMon build for now. - 412e994 Added appveyor.yml for automatized Windows build on appyevor: https://ci.appveyor.com Needs just a registration of the repository similar as Travis and both of them should be able to run at the same time: https://github.com/blog/1935-see-results-from-all-pull-request-status-checks - d92746a Changed .travis.yml in a way that instead of using the root-system from the Ubuntu repository which is traditionally a bit strange the precompiled version from the CERN root web site is loaded. Now the OnlineMon is reanbled for the Linux build. - 047810b Wrong branch name in appveyor.yml - 638fd78 With the removal of the hand assigned compiler flags (relying on cmake) it also compiles again on OSX. Added modern cmake 3.4 as the provided one is too old: 2.8. + b405426 Add qt to OSX. + 106c5b2 Switched CI settings from v1.5-dev branch to v1.6-dev as 1.6 release has been published. + 21f589b Fixed CI badges for v1.6-dev + 1ae0ffa Formatting README.md v1.6-dev got lost + 8466bfe Forgot to change hard coded version for 1.6 + 3dc0a9b Forgot to change hard coded version for 1.6 + e897f4e Reduce noise in appveyor build (see http://help.appveyor.com/discussions/problems/4569-the-target-_convertpdbfiles-listed-in-a-beforetargets-attribute-at-c-does-not-exist-in-the-project-and-will-be-ignored). + 99376b9 Appveyor CI: Updated appveyor to ROOT 5.34.36 (still for MSVC 2012 but it seems to work...) and Qt 5.6/MSVC 2015. + 4b702dc Travis CI: Updated travis ROOT to 5.34.36 + 906dc5d Travis CI: Creating option branches + 0ffb506 Travis CI: Corrected the file permissions of helper scripts + f2cc2ec Travis CI: More progress on travis options. Renamed travis env variable. Travis env context + dbdf7cf Travis CI: QT5 added + 92372dd Travis CI: Install python3 on travis for modern option + a4ce2d8 Travis CI: Switch on all producers + bc37bf9 Travis CI: Do not build palpidefs on travis as it requires external dependencies + 9ae0e93 Travis CI: Adding openafs to travis + 0707986 Travis CI: Added more producers + 3cf1509 Travis CI: Removed pixelman producer from travis build and checking why afs not recognized + b6a6ddf Travis CI: Added kernel headers for OpenAFS module + 50dbc41 Travis CI: Added openafs repo to travis linux + ea949f1 Travis CI: Start openafs after module installation + d19ae7d Travis CI: Added libusb to travis + 5904a58 Travis CI: For travis download only necessary parts of ZestSC, otherwise awfully slow. + 639fd8b Cmake syntax error + 7b6a31c Travis CI: Removed pybar from travis as it seems to be no longer in 1.6 and following + 4857c1a Travis CI: Removing Altro from build due to known issues + 7a2b477 Travis CI: Removing mvd from travis build due to known issues + 613b669 Travis CI: Removing calice from the travis build until it is fixed + a16e29e Removing depfet from travis build as it fails. + 3b3d24c Travis CI: Readding depfet to travis after Simon's fix + e618a86 Travis CI: Install OpenAFS on Mac + e96e656 Travis CI: Reenable calice option + 7bccc9a Travis CI: Disable eudrb as it is only supposed to run on single board computers + 2c00b5c Appveyor CI: Install OpenAFS on Windows + 5bb53e4 Travis CI: Changing cmake flags + e6fb0c4 Travis CI: Compile manual on linux + ad242e6 Appveyor CI: Remove remote desktop conenction (only for debugging, leave it commented) + 6f5b10e Travis CI: Change cmake parametres + d940170 Travis CI: Change python handling + bbc3553 Fix problem with cmake on mac (framework version mismatch): https://github.com/usnistgov/REFPROP-wrappers/blob/master/cmake/FindPythonLibsNew.cmake pybind/pybind11#99 http://stackoverflow.com/questions/30470628/os-x-cmake-cant-find-pythonlibs-3-4 Homebrew/legacy-homebrew#10393 (comment) + d7fa3d1 Travis CI: Updated root 6 version + 71d0057 Travis CI more work on python installation for mac and linux. + 4fe72ea Appveyor CI: Installation of supporter programs, openafs, ... + 8bb32e5 Appveyor CI: Install python including numpy + c52c1e8 - Solved openafs problem on travis CI - Updated hard coded version to 1.7 - General clean up of CI oriented files - Reverted FINDLIBusb.cmake test output as it is no longer necessary after debugging - Prepared travis and appveyor githb release upload; needs to be tested after merge + b76f64a Appveyor CI: Repair syntax error in yml file. + ceb7d9e Appveyor CI: Fixing artefact generation + 39ae109 CI: Changing branch name for symbols in README.me (show on the top page of github)
Delete CMakeLists.txt which will cache make config .If the first time you use python 2.7 ,the file can remerber python path,and use it . so JUST DELETE CMAKELISTS.TXT! |
Also, it can be helpful to specify the python executable directly like
-DPYTHON_EXECUTABLE=/path/to/python/exe
…On Wed, Dec 20, 2017 at 6:13 AM, MrBean947724451 ***@***.***> wrote:
Delete CMakeLists.txt which will cache make config .If the first time you
use python 2.7 ,the file can remerber python path,and use it . so JUST
DELETE CMAKELISTS.TXT!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#99 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABxha-OJ0-DD2ecc9NAvxLiU975-6qXaks5tCQfngaJpZM4HV3JL>
.
|
i solve my build error by clearing makelists
邮箱:[email protected]
签名由 网易邮箱大师 定制
On 12/21/2017 11:56, Ian Bell wrote: Also, it can be helpful to specify the python executable directly like
-DPYTHON_EXECUTABLE=/path/to/python/exe
On Wed, Dec 20, 2017 at 6:13 AM, MrBean947724451 <[email protected]>
wrote:
Delete CMakeLists.txt which will cache make config .If the first time you
use python 2.7 ,the file can remerber python path,and use it . so JUST
DELETE CMAKELISTS.TXT!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#99 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABxha-OJ0-DD2ecc9NAvxLiU975-6qXaks5tCQfngaJpZM4HV3JL>
.
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/pybind/pybind11","title":"pybind/pybind11","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/pybind/pybind11"}},"updates":{"snippets":[{"icon":"PERSON","message":"@ibell in #99: Also, it can be helpful to specify the python executable directly like\n-DPYTHON_EXECUTABLE=/path/to/python/exe\n\nOn Wed, Dec 20, 2017 at 6:13 AM, MrBean947724451 \[email protected]\u003e\nwrote:\n\n\u003e Delete CMakeLists.txt which will cache make config .If the first time you\n\u003e use python 2.7 ,the file can remerber python path,and use it . so JUST\n\u003e DELETE CMAKELISTS.TXT!\n\u003e\n\u003e —\n\u003e You are receiving this because you commented.\n\u003e Reply to this email directly, view it on GitHub\n\u003e \u003chttps://github.com/pybind/pybind11/issues/99#issuecomment-353059633\u003e, or mute\n\u003e the thread\n\u003e \u003chttps://github.com/notifications/unsubscribe-auth/ABxha-OJ0-DD2ecc9NAvxLiU975-6qXaks5tCQfngaJpZM4HV3JL\u003e\n\u003e .\n\u003e\n"}],"action":{"name":"View Issue","url":"#99 (comment)"}}}
|
cmake -DPYTHON_EXECUTABLE= |
I had to provide the following flags
|
I have written a script to find cmake variables for pyenv python. So basically, add these lines before add_subdirectory(pybind11)
then ${PYTHON_EXECUTABLE}, ${PYTHON_INCLUDE_DIR}, ${PYTHON_NUMPY_INCLUDE_DIR}, ${PYTHON_LIBRARY} of pyenv will be fed into pybind11. |
In case that might help, I found a workaround for a similar problem, looking at the cmake doc : You must set two env vars for cmake to find coherent versions
|
This is needed when using linuxdeploy / appimagecraft to create an AppImage and when cross compiling (f.e. with MXE) to find the python libraries. You may need to set CMAKE_FIND_ROOT_PATH_MODE_LIBRARY to BOTH when cross compiling. This may fix issues pybind#1718, pybind#1159, pybind#1330 and pybind#99.
This is needed when using linuxdeploy / appimagecraft to create an AppImage and when cross compiling (f.e. with MXE) to find the python libraries. You may need to set CMAKE_FIND_ROOT_PATH_MODE_LIBRARY to BOTH when cross compiling. This may fix issues pybind#1718, pybind#1159, pybind#1330 and pybind#99.
This is needed when using linuxdeploy / appimagecraft to create an AppImage and when cross compiling (f.e. with MXE) to find the python libraries. You may need to set CMAKE_FIND_ROOT_PATH_MODE_LIBRARY to BOTH when cross compiling. This may fix issues pybind#1718, pybind#1159, pybind#1330 and pybind#99.
I had the same problem, and once I managed to solve this problem - which was adding a couple lines setting the variables python_library and python_include in the Cmakelists.txt , I ran into Boost problems. The way I solved this was uninstalling python using homebrew and reinstalling python and linking it properly. After that pip3 install . worked in one go. |
This is needed when using linuxdeploy / appimagecraft to create an AppImage and when cross compiling (f.e. with MXE) to find the python libraries. You may need to set CMAKE_FIND_ROOT_PATH_MODE_LIBRARY to BOTH when cross compiling. This may fix issues pybind#1718, pybind#1159, pybind#1330 and pybind#99.
FYI: still an issue with latest cmake, cf: |
updates: - [github.com/asottile/pyupgrade: v3.1.0 → v3.2.0](asottile/pyupgrade@v3.1.0...v3.2.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
it's worth noting that: * One needs `-DPython...` or `-DPython3...` depending on whether the respective CMakeLists.txt does `find_package(Python ...)` or `find_package(Python3 ...)`. [0] * The error messages are actively misleading, as ``` Could NOT find Python (missing: Python_INCLUDE_DIRS Python_LIBRARIES Python_NumPy_INCLUDE_DIRS Development NumPy Development.Module Development.Embed) ``` suggests that the variables in question use plural `_DIRS` / `_LIBRARIES`, yet what's actually required is the singular. [1] * The key flag is `Python_NumPy_INCLUDE_DIR`; other times `Python_EXECUTABLE` or `Python_ROOT` may prove useful. Inspired by work [2] from the pinocchio-feedstock (thank you!), though the actual copying turns out to not be necessary. And if you've read this far, you get this lovely bonus comment [3]. :) [0] https://github.com/facebookresearch/faiss/blob/v1.8.0/faiss/python/CMakeLists.txt#L153 [1] https://cmake.org/cmake/help/latest/module/FindPython.html [2] https://github.com/conda-forge/pinocchio-feedstock/blob/main/recipe/build.sh [3] pybind/pybind11#99 (comment)
CMake finds mismatched PythonLibs and PythonInterp on my machine with multiple Python installations. PythonLibs finds 2.7.10, while PythonInterp finds 2.7.11:
Specifying -DPYTHON_INCLUDE_DIR seems to bypass the error, though it warns that EXACT is being ignored. However, PythonInterp now finds Python 3.5.1:
I have three Pythons installed, 2.7.11 and 3.5.1 via homebrew in
/usr/local/bin/
, and 2.7.10 via the OSX system installation in/usr/bin/
:/usr/local/bin/python
is expected to be found first in PATH:From a related closed pull request, this appears to be the fault of CMake ( https://github.com/wjakob/pybind11/pull/65 ), not specifically pybind11. Still, it would be nice to have a safe workaround, as having homebrew and system Python installations will likely be common for users in OSX environments. I'll take a closer look tonight.
Some version information:
The text was updated successfully, but these errors were encountered: