Python中文
首页
教程
问答
标签
搜索
登录
注册
导入python boost modu
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我用boost::python在VS2010中构建了一个DLL,将一些函数导出到python模块:</p> <p>在我的dll.cpp公司名称:</p> <pre><code>std::string greet() { return "hello, world"; } int square(int number) { return number * number; } BOOST_PYTHON_MODULE(getting_started1) { // Add regular functions to the module. def("greet", greet); def("square", square); } </code></pre> <p>到目前为止,一切都很好。然后我得到我的dll.dll以及我的dll.libc:\myDLL\Debug中的文件。在</p> <p>据boost医生说(http://wiki.python.org/moin/boost.python/SimpleExample),我需要将此添加到PYTHONPATH,因此我将c:\myDLL\Debug添加到它: Python: C: \Python27;C:\myDLL\Debug</p> <p>然后,从我的.py文件中,我尝试导入它:</p> ^{pr2}$ <p>我也尝试过从myDLL import获取_started1,从getting_started1 import*,以及所有可能的组合。在</p> <p>有人能告诉我怎么给我的模块打电话吗?谢谢</p> <p>编辑: 根据cgohlke的说法,当我在VS中编译时,PYTHONPATH的某个地方应该有一个getting-unstarted1.pyd?此文件不存在。。。我需要在VS2010中设置一些不同的东西吗?我有一个默认的win32 DLL项目。 但是boost文档说“如果我们构建这个共享库并把它放到PYTHONPATH上”,windows上的共享库不是DLL吗?因此,DLL应该在PYTHONPATH中?在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<ol> <li>我设法让它只在发布配置中工作,而不在调试中工作。在</li> <li>在“项目属性”的“常规”选项卡上,将目标扩展名修改为.pyd</li> <li>项目确实应该是一个dll,正如您所做的那样</li> <li>在Python脚本中,需要指定dll的位置,如下例所示: 导入系统 系统路径追加(“d:\\TheProjectl\\bin\\Release”) 导入没有扩展名的getting#Dll名称</li> </ol>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
尽管Python中的所有内容都是引用,为什么Python导师在没有指针的列表中绘制字符串和整数?
3 回答
尽管python中的表达式为false,但循环仍在运行
1 回答
尽管python代码正确,但从nifi ExecuteScript处理器获取语法错误
9 回答
尽管Python在Neovim中工作得很好,但插件不能识别Neovim中的Python主机
5 回答
尽管python字典包含了大量的条目,但它并没有增长
9 回答
尽管python说模块存在,为什么我会得到这个消息?
8 回答
尽管setuptools和控制盘是最新的,但无法识别singleversionexternallymanaged
4 回答
尽管stdout和stderr重定向,但未捕获错误消息
1 回答
尽管Tensorboard的事件太大,但Tensorboard的步骤太少了
8 回答
尽管tkinter上的变量已更改,但显示未更改
4 回答
尽管try/except使用Python进行单元测试时出现断言错误
2 回答
尽管URL是sam,但仍会抛出“达到最大重定向”
2 回答
尽管url有效,Pandas仍读取url的\u csv错误
2 回答
尽管while中存在时间延迟,但LINUX线程的CPU利用率为100%(1)
9 回答
尽管x0在范围内,Scipy优化仍会引发ValueError
4 回答
尽管xpath正确,但使用selenium单击链接仍不起作用
3 回答
尽管下载了ffmpeg并设置了路径变量python,但没有后端错误
5 回答
尽管下载了i,但找不到型号“fr”
7 回答
尽管下载了plotnine包,但未获取名为“plotnine”的模块时出错
7 回答
尽管为所有行指定了权重,网格(0)仍不起作用
2 回答