Python google 云函数部署失败 - websockets
Python google cloud function deployment failure - websockets
我正在尝试从 Google 源代码部署 python 脚本,但在尝试从 websockets 库导入 create_connection
时失败。
这是我的脚本的顶部。它在导入 gemini 包时失败,而 gemini 包又导入了 websockets:
import json
import os
from gemini import PrivateClient
和我的requirements.txt
gemini-python==0.2.1
Google Cloud Functions 日志显示此错误:
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 Functions 不支持 WebSocket。
您可能需要考虑替代计算服务,例如 Cloud 运行 does
我正在尝试从 Google 源代码部署 python 脚本,但在尝试从 websockets 库导入 create_connection
时失败。
这是我的脚本的顶部。它在导入 gemini 包时失败,而 gemini 包又导入了 websockets:
import json
import os
from gemini import PrivateClient
和我的requirements.txt
gemini-python==0.2.1
Google Cloud Functions 日志显示此错误:
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 Functions 不支持 WebSocket。
您可能需要考虑替代计算服务,例如 Cloud 运行 does