Skip to content

cannot open source file "Python.h" (dependency of "pybind11/pybind11.h") issue even though correct file path is included #10

@Sstoica24

Description

@Sstoica24

Hello,
I am getting a "cannot open source file "Python.h" (dependency of "pybind11/pybind11.h")" or " "#include errors detected. Please update your includePath. Squiggles are disabled" error when I try to #include <pybind11/pybind11.h> in the simple_ml_ext.cpp file even though the correct file path "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pybind11/include/pybind11", which is where pybind11.h is located in the terminal (I checked this by doing ls /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pybind11/include/pybind11), has been added to the IncludePath settings in VS code, the text editor I am using.

When I try to run the
"!make
!python3 -m pytest -k "softmax_regression_epoch_cpp""
testing cell in hw0.ipynb, I get the following issue:
c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) src/simple_ml_ext.cpp -o src/simple_ml_ext.so
Undefined symbols for architecture x86_64:
"_PyBaseObject_Type", referenced from:
pybind11::detail::make_object_base_type(_typeobject*) in simple_ml_ext-629c88.o
"_PyBuffer_Release", referenced from:
std::_1::enable_if<std::is_void::value, pybind11::detail::void_type>::type pybind11::detail::argument_loader<pybind11::array_t<float, 1>, pybind11::array_t<unsigned char, 1>, pybind11::array_t<float, 1>, float, int>::call<void, pybind11::detail::void_type, pybind11_init_simple_ml_ext(pybind11::module&)::$0&>(pybind11_init_simple_ml_ext(pybind11::module&)::$_0&) && in simple_ml_ext-629c88.o
"_PyByteArray_AsString", referenced from:
bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator>, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in simple_ml_ext-629c88.o
"_PyByteArray_Size", referenced from:
bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator>, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in simple_ml_ext-629c88.o
"_PyByteArray_Type", referenced from:
bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator>, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in simple_ml_ext-629c88.o
"_PyBytes_AsString", referenced from:
bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator>, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in simple_ml_ext-629c88.o
"_PyBytes_AsStringAndSize", referenced from:
pybind11::detail::error_fetch_and_normalize::format_value_and_trace() const in simple_ml_ext-629c88.o
pybind11::str::operator std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator>() const in simple_ml_ext-629c88.o
"_PyBytes_Size", referenced from:
bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator>, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in simple_ml_ext-629c88.o
"_PyCFunction_Type", referenced from:
pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in simple_ml_ext-629c88.o
"_PyCMethod_New", referenced from:
pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in simple_ml_ext-629c88.o
"_PyCapsule_GetContext", referenced from:
pybind11::capsule::initialize_with_void_ptr_destructor(void const*, char const*, void ()(void))::'lambda'(_object*)::operator()(_object*) const in simple_ml_ext-629c88.o
...

Also, when I tried doing "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pybind11/include/pybind11/pybind11.h" in the terminal I got "permission denied".

How do I fix this?

Thank you,
Sofia

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions