在Mac上的Python 2.7.3中导入.pyd(使用SWIG创建) [英] Importing a .pyd (created with SWIG) in Python 2.7.3 on Mac

查看:100
本文介绍了在Mac上的Python 2.7.3中导入.pyd(使用SWIG创建)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在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创建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆