【问题标题】:can't import pubsub for python SDK appengine / psutil无法为 python SDK appengine / psutil 导入 pubsub
【发布时间】:2018-05-27 13:04:37
【问题描述】:

在我使用 pubsub 和 Google App Engine 时,我在尝试导入 pubsub_v1 时遇到了 psutil 的一些问题。 当我单独运行 Pubsub 时,它做得很好,但是当我将 dev_appserver 用于应用引擎时,我得到了这个回溯:

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 上失败了。

【问题讨论】:

    标签: python python-2.7 google-app-engine google-cloud-pubsub


    【解决方案1】:

    您使用的是 App Engine 标准还是 flex?我假设您使用的是基于日志的标准。

    简短的回答是,Google App Engine 标准目前似乎并不能很好地完全支持谷歌云客户端库。看看这个线程:https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3892。通过模拟 psutil 在这个线程中有一个解决方法,但我自己没有尝试过。

    在这个问题里面,它给你指出了这个问题:https://github.com/GoogleCloudPlatform/google-cloud-python/issues/1893,它正在跟踪状态。此刻它仍然开放。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多