所以最近我一直在尝试使用 pip install --target 将新模块安装到 RhinoScript python 中。我正在做的项目是一台计算机将从我用 pygame.midi 设置的钢琴中捕获 midi,然后通过 pubnub 将该 midi 数据传输到运行自定义 rhinoscript 插件的计算机,该插件将解释数据。
这是我一半复制一半写的 PubNub 界面
from pubnub.pubnub import PubNub
from pubnub.pnconfiguration import PNConfiguration
from pubnub.callbacks import SubscribeCallback
from pubnub.enums import PNOperationType, PNStatusCategory
pnconfig = PNConfiguration()
pnconfig.subscribe_key = 'mysubkey'
pnconfig.publish_key = 'mypubkey'
pubnub = PubNub(pnconfig)
class MySubscribeCallback(SubscribeCallback):
def status(self, pubnub, status):
pass
# The status object returned is always related to subscribe but could contain
# information about subscribe, heartbeat, or errors
# use the operationType to switch on different options
if status.operation == PNOperationType.PNSubscribeOperation \
or status.operation == PNOperationType.PNUnsubscribeOperation:
if status.category == PNStatusCategory.PNConnectedCategory:
print(status)
# This is expected for a subscribe, this means there is no error or issue whatsoever
elif status.category == PNStatusCategory.PNReconnectedCategory:
pass
# This usually occurs if subscribe temporarily fails but reconnects. This means
# there was an error but there is no longer any issue
elif status.category == PNStatusCategory.PNDisconnectedCategory:
pass
# This is the expected category for an unsubscribe. This means there
# was no error in unsubscribing from everything
elif status.category == PNStatusCategory.PNUnexpectedDisconnectCategory:
pass
# This is usually an issue with the internet connection, this is an error, handle
# appropriately retry will be called automatically
elif status.category == PNStatusCategory.PNAccessDeniedCategory:
pass
# This means that PAM does allow this client to subscribe to this
# channel and channel group configuration. This is another explicit error
else:
pass
# This is usually an issue with the internet connection, this is an error, handle appropriately
# retry will be called automatically
elif status.operation == PNOperationType.PNSubscribeOperation:
# Heartbeat operations can in fact have errors, so it is important to check first for an error.
# For more information on how to configure heartbeat notifications through the status
# PNObjectEventListener callback, consult <link to the PNCONFIGURATION heartbeart config>
if status.is_error():
pass
# There was an error with the heartbeat operation, handle here
else:
pass
# Heartbeat operation was successful
else:
pass
# Encountered unknown status type
def presence(self, pubnub, presence):
pass # handle incoming presence data
def message(self, pubnub, message):
print(message.message)
pubnub.add_listener(MySubscribeCallback())
def publish_callback(result, status):
pass
# Handle PNPublishResult and PNStatus
def publishAMessage():
while True:
messageinput = input("what would you like to say: ")
pubnub.publish().channel('zanescustomkey').message([messageinput]).async(publish_callback)
pubnub.subscribe().channels('zanescustomkey').execute()
print('reached the end')
将其放入 RhinoScript 时,会出现导入错误
Message: No module named queue
Traceback:
line 6, in <module>, "C:\Program Files\Rhinoceros 5 (64-bit)\Plug-ins\IronPython\Lib\pubnub\pubnub.py"
line 2, in <module>, "C:\Users\zanem\OneDrive\Documents\PubNub\pythontest.py"
在 IronPython 网站上,基本上就是 RhinoScript,他们说他们支持多处理器。你们中的任何人都知道我将如何将队列导入 Rhinoscript,似乎 PubNub 或 Rhinoscript 文档中没有任何关于此的内容。