Python头文件和库文件(lib)在“properties>;VC++目录”中说明 /Python安装文件夹中的Lib放在.vcxproj文件夹中 .py位于包含.exe的发行版文件夹中
#include <iostream>
#include <pybind11/embed.h>
namespace py = pybind11;
int main()
{
py::scoped_interpreter guard{}; // start the interpreter and keep it alive
py::print("Hello, World!"); // use the Python API
int i;
std::cin >> i;
return 0;
}
这个代码运行到目前为止,所以我想到目前为止,我做的一切都是对的。你知道吗
我已经测试了嵌入,这也有效。你知道吗
计算py
def add(a, b):
return a+b
我放置文件的位置
我把计算py在release文件夹中运行.exe和以下程序:
#include
#include <pybind11/embed.h>
namespace py = pybind11;
int main()
{
py::scoped_interpreter guard{}; // start the interpreter and keep it alive
py::module calc = py::module::import("calc");
py::object result = calc.attr("add")(1, 2);
int n = result.cast<int>();
std::cout << "The result: " << n << std::endl;
int i;
std::cin >> i;
return 0;
}
我想嵌入这个应用:https://github.com/LevPasha/Instagram-API-python 我需要怎么做才能从这个文件中调用构造函数:https://github.com/LevPasha/Instagram-API-python/blob/master/InstagramAPI/InstagramAPI.py
我已经用pip安装了存储库,我知道我用pip show InstagramAPI找到了它的安装文件夹。我是否需要再次将这些文件放在VisualStudio项目的发行版文件夹中?你知道吗
这些是Instagram Api的依赖项:
需要:请求,请求工具带,moviepy
我需要考虑他们吗?你知道吗
我已经绝望了,因为我已经试了好几天了。请帮帮我。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐