首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sikuli使用Python模块(PushBullet)生成AttributeError

Sikuli使用Python模块(PushBullet)生成AttributeError
EN

Stack Overflow用户
提问于 2017-04-17 07:45:25
回答 1查看 267关注 0票数 2

我在编码方面相当新手,我正在尝试在我的PushBullet代码中使用Sikuli API (来自Azelphur)。我使用pip安装PushBullet及其依赖项。以下代码在Atom编辑器中运行良好,但在Sikuli中遇到错误:

代码语言:javascript
复制
from pushbullet.pushbullet import pushbullet

apiKey = "EXAMPLE"
send = PushBullet(apiKey)

devices = send.getDevices()

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

在Sikuli IDE中,我添加了以下路径(之前无法找到模块):

代码语言:javascript
复制
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")

但是,它返回以下内容:

代码语言:javascript
复制
[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中工作(现在我已经添加了路径)?感谢您的任何想法!

EN

回答 1

Stack Overflow用户

发布于 2017-05-04 06:32:19

Sikuli基于Jython,而不是标准Python。也许Atom使用Python解释器来运行代码,但Sikuli IDE使用Jython解释器,这可能是它看不到模块也不能运行它的原因。

您可能想研究一下jpushbullet ( https://github.com/silk8192/jpushbullet ),以及如何在Jython / Sikuli中混合使用Java和Python代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43443357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档