2017-04-16 110 views
2

我在編碼方面比較新,我試圖在我的Sikuli代碼中使用PushBullet API(從Azelphur)。我用pip來安裝PushBullet及其依賴項。下面的代碼功能完美地在Atom編輯器,但在命中錯誤Sikuli:Sikuli使用Python模塊生成AttributeError(PushBullet)

import sys 
sys.path.append("/Library/Python/2.7/site-packages") 
sys.path.append("/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python") 

:在Sikuli IDE我已經添加了這些路徑(它無法找到之前的模塊)

from pushbullet.pushbullet import pushbullet 

apiKey = "EXAMPLE" 
send = PushBullet(apiKey) 

devices = send.getDevices() 

send.pushNote(devices[0]["iden"], "Hello World", "Test") 

但是它返回:

[error] script [ pushsample ] stopped with error in line 5 
[error] AttributeError ('module' object has no attribute 'SOL_TCP') 
[error] --- Traceback --- error source first 
line: module (function) statement 
30: _socket (<module>) DEFAULT_SOCKET_OPTION = [(socket.SOL_TCP, socket.TCP_NODELAY, 1)] 
31: _http (<module>) from ._socket import* 
29: _handshake (<module>) from ._http import * 
33: _core (<module>) from ._handshake import * 
35: _app (<module>) from ._core import WebSocket, getdefaulttimeout 
23: __init__ (<module>) from ._app import WebSocketApp 
18: pushbullet (<module>) from websocket import create_connection 
[error] --- Traceback --- end -------------- 

爲什麼它的Atom工作,但不Sikuli IDE(現在我已經添加了路徑)?感謝您的任何想法!

回答

0

Sikuli基於Jython,不是標準的Python。也許Atom使用Python解釋器來運行代碼,但Sikuli IDE使用Jython解釋器,這可能是它看不到模塊並且無法運行它的原因。

您可能想要查看jpushbullet(https://github.com/silk8192/jpushbullet)以及如何在Jython/Sikuli中混合使用Java和Python代碼。

相關問題