0

I tried the cmake_example project provided by the pybind11 docs https://github.com/pybind/cmake_example. Running the cmake file worked and it created a folder named cmake_example.dir in the build/x 64-Debug/CMakeFiles folder. However that folder only contains another one named src and nothing else.

When trying to run the test file test_basic.py it gives me an error saying it cant find the module cmake_example. Probably because there wasn't any .pyd file created no? Why is that the case and how can I fix this?

EDIT: The .pyd file exists now in the output directory (I just had to build after generating the cache), however the python test still cant import the module saying ModuleNotFoundError: No module named cmake_example

Nova
  • 50
  • 8
  • "Running the cmake file worked" - Do you mean that you run `cmake` (with some arguments)? That command just **configures** the project. For **building** the project, you need to run generator-specific command. E.g. on Linux it is usually `make`. – Tsyvarev Feb 04 '22 at 07:55
  • Generating the Cache and building the file works now. Importing the generated file doesn't -> `unresolved import "cmake_example"` -> i imported it using `import cmake_example as m` – Nova Feb 04 '22 at 09:41
  • You probably need to point Python where to search your module. See e.g. that question: https://stackoverflow.com/questions/4580101/python-add-pythonpath-during-command-line-module-run – Tsyvarev Feb 04 '22 at 09:46
  • i have tried that using `import os current_file_path = os.path.dirname(os.path.abspath(__file__)) import sys sys.path.append(current_file_path + "../out//build/x64-Debug") import cmake_example as m` Didn't change anything sadly. – Nova Feb 04 '22 at 10:04

0 Answers0