对于这个问题(stackoverflow.com/questions/4086435/),我尝试制作 Python 3 版本的库 python-websocket(github.com/mtah/python-websocket/),这是我的代码:https:// gist.github.com/663175。
Blender 带有他自己的 Python 3.1 包,所以我直接将我的文件添加到它的 «site-packages» 文件夹中。我现在收到此错误:
回溯(最近一次通话最后): 文件“websocket.py”,第 6 行,在 AttributeError:“模块”对象没有属性“WebSocket”
在 Blender 中运行此代码时:
import sys, os, asyncore, websocket
def msg_handler(msg):
print(msg)
socket = websocket.WebSocket('ws://localhost:8080/', onmessage=msg_handler)
socket.onopen = lambda: socket.send('Hello world!')
try:
asyncore.loop()
except KeyboardInterrupt:
socket.close()
我发现 a__init__.py
是必需的,所以我添加了但它没有帮助......我在这里做错了什么?谢谢你的帮助。