Python谷歌云功能部署失败-websockets



我正试图从谷歌源代码中部署一个python脚本,但在尝试从websockets库导入create_connection时失败了。

这是我剧本的顶部。它在导入gemini包的过程中失败,而gemini包又在导入websocket:

import json
import os
from gemini import PrivateClient

和我的requirements.txt

gemini-python==0.2.1

谷歌云功能日志显示此错误:

Traceback (most recent call last):
File "/layers/google.python.pip/pip/bin/functions-framework", line 8, in <module>
sys.exit(_cli())
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/functions_framework/_cli.py", line 37, in _cli
app = create_app(target, source, signature_type)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/functions_framework/__init__.py", line 255, in create_app
spec.loader.exec_module(source_module)
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/workspace/main.py", line 7, in <module>
import gemini
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gemini/__init__.py", line 3, in <module>
from .basewebsocket import BaseWebSocket
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gemini/basewebsocket.py", line 9, in <module>
from websocket import create_connection, WebSocketConnectionClosedException
ImportError: cannot import name 'create_connection' from 'websocket' (/layers/google.python.pip/pip/lib/python3.8/site-packages/websocket/__init__.py)

这个脚本使用Python 3.8在我的Mac上运行。不确定该怎么办,因为这似乎是特定于环境的。感谢您的帮助。

Cloud函数不支持WebSockets。

你可能想考虑一种替代的计算服务,比如云运行,它可以进行

相关内容

  • 没有找到相关文章

最新更新