当我在pubsub和Google App Engine上工作时,当我尝试导入pubsub_v1时,我遇到了psutil的一些问题。 当我单独运行时,Pubsub做得很好但是当我使用dev_appserver作为app引擎时,我得到了这个回溯:
Traceback (most recent call last):
File "/Users/soussa77/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/soussa77/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Users/soussa77/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 96, in LoadObject
__import__(cumulative_path)
File "/Users/soussa77/PycharmProjects/my-project/apps/app1/src/main.py", line 4, in <module>
from src.apis.app1 import App1Api
File "/Users/soussa77/PycharmProjects/my-project/apps/app1/src/apis/app1.py", line 11, in <module>
from google.cloud import pubsub_v1
File "/Users/soussa77/PycharmProjects/my-project/apps/app1/lib/google/cloud/pubsub_v1/__init__.py", line 17, in <module>
from google.cloud.pubsub_v1 import types
File "/Users/soussa77/PycharmProjects/my-project/app/waterp/lib/google/cloud/pubsub_v1/types.py", line 17, in <module>
import psutil
File "/Users/soussa77/PycharmProjects/my-project/apps/app1/lib/psutil/__init__.py", line 156, in <module>
from . import _psosx as _psplatform
File "/Users/soussa77/PycharmProjects/my-project/apps/app1/lib/psutil/_psosx.py", line 16, in <module>
from . import _psutil_osx as cext
File "/Users/soussa77/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 1091, in load_module
raise ImportError('No module named %s' % fullname)
**ImportError: No module named psutil._psutil_osx**
当pubsub尝试监视cpu活动时,看起来它在psutil失败。
答案 0 :(得分:1)
您使用的是App Engine标准还是flex?我假设您正在使用基于日志的标准。
简短的回答是,谷歌应用引擎标准似乎并不能完全支持谷歌云客户端lib。看一下这个帖子:https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3892。通过模拟psutil
,这个线程有一个解决方法,但我自己没有尝试过。
在此问题中,它指出了这个问题:https://github.com/GoogleCloudPlatform/google-cloud-python/issues/1893正在跟踪状态。它现在仍然是开放的。