dlsyscourse / hw0

14 stars 23 forks source link

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

Open Sstoica24 opened 10 months ago

Sstoica24 commented 10 months ago

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_mlext(pybind11::module&)::$_0&>(pybind11_init_simple_mlext(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