导入apache_beam

时间:2017-08-13 13:18:20

标签: python google-app-engine apache-beam

我有一个App Engine应用程序,它打破了我做的那一刻

import apache_beam

我可以确认应用程序运行的虚拟环境中是否安装了依赖项。根据下面的堆栈跟踪判断它看起来像是因为某些原因而尝试访问/ dev / null而它没有。

INFO     2017-08-13 13:03:37,980 stubs.py:50] Sandbox prevented access to file "/home/raul/Downloads/google-cloud-sdk"
INFO     2017-08-13 13:03:37,980 stubs.py:51] If it is a static file, check that `application_readable: true` is set in your app.yaml
INFO     2017-08-13 13:03:37,980 stubs.py:50] Sandbox prevented access to file "/home/raul/Downloads/google-cloud-sdk/platform"
INFO     2017-08-13 13:03:37,980 stubs.py:51] If it is a static file, check that `application_readable: true` is set in your app.yaml
INFO     2017-08-13 13:03:38,260 stubs.py:50] Sandbox prevented access to file "/dev/null"
INFO     2017-08-13 13:03:38,260 stubs.py:51] If it is a static file, check that `application_readable: true` is set in your app.yaml
ERROR    2017-08-13 13:03:38,261 wsgi.py:263] 
Traceback (most recent call last):
  File "/home/raul/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/home/raul/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/home/raul/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/home/raul/Documents/football/main.py", line 7, in <module>
    import apache_beam
  File "/home/raul/Documents/football/env/lib/python2.7/site-packages/apache_beam/__init__.py", line 75, in <module>
    import apache_beam.internal.pickler
  File "/home/raul/Documents/football/env/lib/python2.7/site-packages/apache_beam/internal/pickler.py", line 38, in <module>
    import dill
  File "/home/raul/Documents/football/env/lib/python2.7/site-packages/dill/__init__.py", line 27, in <module>
    from .dill import dump, dumps, load, loads, dump_session, load_session, \
  File "/home/raul/Documents/football/env/lib/python2.7/site-packages/dill/dill.py", line 165, in <module>
    FileType = type(open(os.devnull, 'rb', buffering=0))
  File "/home/raul/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 260, in __init__
    raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/dev/null'

任何可能导致此问题以及如何解决问题的想法?

1 个答案:

答案 0 :(得分:1)

GAE Python sandbox在您的应用代码允许的范围方面非常严格。看起来dill使用的apache-beam包需要访问特殊文件(在这种情况下为/dev/null设备文件),这是沙盒上不允许的。

您要么更改代码以满足所有沙箱要求,要么尝试使用the flexible environment,这是更宽容的(但它总体上是一个不同的野兽)。请参阅Choosing an App Engine EnvironmentMigrating Services from the Standard Environment to the Flexible Environment

旁注:回溯表明您的应用尝试从本地系统安装执行apache-beam,这也不会在标准环境中工作 - 需要将其存入您的应用程序,请参阅{{3} }。