[BUG]: can't find python38.dll so the program can't continue
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
Problem description
i tried to call python from c++. I installed python3.8.10 by anaconda on my computer and at first, the CMake failed. I realized this was because pybind11 can't find the install path of python, so i modified the commands of CMake into:
cmake_minimum_required(VERSION 3.4)
project(call_python)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
set(pybind11_DIR C:/Users/25963/anaconda3/Library/share/cmake/pybind11)
find_package(pybind11 CONFIG REQUIRED)
add_executable(call_python main.cpp)
target_link_libraries(call_python PRIVATE pybind11::embed)
so that it can find the install path. Then CMake succeeded. But then when i ran the C++ codes, it said that the python38.dll can't be found.
Reproducible example code
#include <pybind11/embed.h> // everything needed for embedding
namespace py = pybind11;
using namespace py::literals;
int main() {
py::scoped_interpreter guard{};
auto kwargs = py::dict("name"_a = "World", "number"_a = 42);
auto message = "Hello,{name}.The answer is{number}"_s.format(**kwargs);
py::print(message);
py::module_ sys = py::module_::import("sys");
//py::object scipy = py::module_::import("scipy");
py::print(sys.attr("path"));
//py::print(scipy.attr("__version__"));
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Windows build from the CMake configuration in the issue with the provided main.cpp and the Anaconda Python 3.8 environment. Inspect the generated executable's runtime dependency path and pybind11's embedding configuration; done means the example launches without a missing python38.dll error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100