Check CMakeLists.txt: Ensure your CMakeLists.txt includes the proper PyBind11 configuration:
cmake_minimum_required(VERSION 3.12) project(cmake_example)
set(CMAKE_CXX_STANDARD 14) find_package(pybind11 REQUIRED)
pybind11_add_module(cmake_example src/main.cpp)
2.Rebuild the Project: After confirming the CMakeLists.txt is correct, rebuild the project by running:
Code: python setup.py build
3.Ensure Correct Python Version: Verify that the Python version used in your virtual environment matches the one used during the build process (python --version).
4.Check the Build Output: After rebuilding, check the output directory for the .pyd file (e.g., cmake_example.cp311-win_amd64.pyd) and make sure it's in your Python path (e.g., same directory as the test script). Then run the test again.