pybind11
pybind11 copied to clipboard
[QUESTION] Cannot import 'sysconfig' during cmake configuration
Hi, my project builds fine in dev environment, but when I throw it into a drone CI docker image it gives me the following error:
-- pybind11 v2.6.2 dev1
-- Found PythonInterp: /usr/bin/python3.6 (found version "3.6.9")
CMake Error at python/pybind/tools/FindPythonLibsNew.cmake:131 (message):
Python config failure:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'sysconfig'
Call Stack (most recent call first):
python/pybind/tools/pybind11Tools.cmake:38 (find_package)
python/pybind/tools/pybind11Common.cmake:201 (include)
python/pybind/CMakeLists.txt:169 (include)
I tried building directly in the docker image and it also builds fine. I also tried importing the sysconfig package in the python REPL and it also works fine. Any idea what's causing this?
@hyt589 Can you reproduce this in a docker image that's available for us to try?
Pybind's cmake is doing from distutils import sysconfig as s, not import sysconfig as s.
Installing python3-distutils solved it for me.
I installed python3-distutils, the error persisted. The clue lies in the error itself actually. The error is
-- Found PythonInterp: /usr/bin/python3.7 (found version "3.7.5")
CMake Error at /usr/lib/cmake/pybind11/FindPythonLibsNew.cmake:96 (message):
Python config failure:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'sysconfig' from 'distutils'
(/usr/lib/python3.7/distutils/__init__.py)
When I run python3 in a terminal, it gives me a version 3.8. So with synaptic package manager, I uninstalled all packages related to python 3.7. Then the error vanished.