作者uranusjr (←这人是超级笨蛋)
看板Python
标题Re: [问题] import moudle on mac
时间Wed Aug 7 21:39:07 2013
※ 引述《MAGICXX (逢甲阿法)》之铭言:
: 我自己compile出一个libTRANING.pyd的档案要给我的python程式码使用
: import imp
: imp.find_module('TRANING',[r'/Applications/QGIS.app/plugins/my_lib/'])
: 因为在mac下面lib的名称是lib"name".附档名(dylib,pyd等)
Read the doc.
http://docs.python.org/2/library/imp.html
imp.find_module(name[, path])
[...]
Otherwise, path must be a list of directory names;
each directory is
searched for files with any of the suffixes returned by get_suffixes()
above. Invalid names in the list are silently ignored (but all list items
must be strings).
打开 interpreter
>>> import imp
>>> imp.get_suffixes()
[('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), ('.pyc', 'rb', 2)]
>>>
没有 .pyd
所以当然找不到
请编成 .so 或使用 .pyc (not a good idea IMO)
--
Les grandes et les meilleurs
tone from "Zadok the Priest"
Eine grosse stattliche Veranstaltung
by F. Handel
THE MAIN EVENT! These are the men
Sie sind die Besten
"Champions League" by Tony Britten THESE ARE THE CHAMPIONS!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.32.81.146
1F:推 MAGICXX:感谢大大的回复 可是因为之前再windows下是可以吃pyd的 08/07 23:24
2F:→ MAGICXX:意思是 同样的程式码 在WINDOWS下是正常可以运作的 08/07 23:25
3F:→ MAGICXX:所以才在想 在MAC下是不是有甚麽不同~@@!? 08/07 23:25
4F:推 MAGICXX:抱歉 我看懂了 在WINDOW下 是可以吃的 在MAC下是不行的 08/07 23:29