问题描述
我已经在Windows下用SWIG创建了一个.pyd文件,名为(_example.pyd).
I have created a .pyd file with SWIG under Windows named (_example.pyd).
我能够通过以下简单命令将文件发送到我的电子邮件中,并使用相同版本的Python(Python 2.7.3)将其导入另一台Windows计算机:
I am able to send the file to my email and import it with another Windows machine using the same version of Python (Python 2.7.3) with this simple command:
.>>> import _example
.>>>
但是,当我将其发送到我的电子邮件并尝试使用Mac导入文件时,我得到了:
But when I send it to my email and tried to import the file with a Mac, I get:
"No module named _example"
有什么想法吗?
在两种情况下,我都将文件保存到Python路径中.
In both cases, I saved the file into the Python path.
推荐答案
这是因为Python扩展(.pyd文件)本质上是DLL.
如果要在Mac上使用扩展程序,则需要在Mac上/在Mac上进行编译.
This is because Python extensions (.pyd files) are essentially DLLs.
If you want to use your extension on a Mac, you will need to compile it for/on a Mac.
http://docs.python.org/faq/windows.html#is-a-pyd-file-the-same-as-a-dll
这篇关于在Mac上的Python 2.7.3中导入.pyd(使用SWIG创建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!