Re: [問題] import moudle on mac

看板Python作者 (←這人是超級笨蛋)時間12年前 (2013/08/07 21:39), 編輯推噓2(202)
留言4則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《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

08/07 23:24, , 1F
感謝大大的回復 可是因為之前再windows下是可以吃pyd的
08/07 23:24, 1F

08/07 23:25, , 2F
意思是 同樣的程式碼 在WINDOWS下是正常可以運作的
08/07 23:25, 2F

08/07 23:25, , 3F
所以才在想 在MAC下是不是有甚麼不同~@@!?
08/07 23:25, 3F

08/07 23:29, , 4F
抱歉 我看懂了 在WINDOW下 是可以吃的 在MAC下是不行的
08/07 23:29, 4F
文章代碼(AID): #1I0at-ll (Python)
討論串 (同標題文章)
文章代碼(AID): #1I0at-ll (Python)