本地主机上的应用程序引擎 std 的 devappserver.py 正在清除 OS.uname 并在 ctypes 中崩溃



我愚蠢地重新安装了所有Python 2.7依赖项,但它破坏了一些东西。如果您在第1行注意到,os.uname((有一个有效值,但当GAE调用ctypes模块(第3行(时,它已经被清空,我的本地服务器不会响应客户端。

这感觉有点过头了&如果有任何指导,我将不胜感激。

os.uname() is: 19.3.0
INFO     2020-03-04 19:11:42,584 instance.py:294] Instance PID: 8624
os.uname() is: 
ERROR    2020-03-04 19:11:43,311 wsgi.py:269] 
Traceback (most recent call last):
  File "/Users/dgaedcke/gcloud_tools/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/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 311, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 96, in LoadObject
    __import__(cumulative_path)
  File "/Users/dgaedcke/dev/TouchstoneMicroservices/service_backend/main.py", line 7, in <module>
    import endpoints as google_cloud_endpoints
  File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/site-packages/endpoints/__init__.py", line 29, in <module>
    from .api_config import api, method
  File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/site-packages/endpoints/api_config.py", line 44, in <module>
    import attr
  File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/site-packages/attr/__init__.py", line 5, in <module>
    from . import converters, exceptions, filters, validators
  File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/site-packages/attr/filters.py", line 7, in <module>
    from ._compat import isclass
  File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/site-packages/attr/_compat.py", line 139, in <module>
    set_closure_cell = make_set_closure_cell()
  File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/site-packages/attr/_compat.py", line 129, in make_set_closure_cell
    ctypes = import_ctypes()
  File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/site-packages/attr/_compat.py", line 95, in import_ctypes
    import ctypes
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 29, in <module>
    if int(_os.uname()[2].split('.')[0]) < 8:
ValueError: invalid literal for int() with base 10: ''

attrs自19.2.0以来就没有使用过ctypes,因此解决方案是以某种方式更新您的依赖关系。

尝试编辑位于devappserver2/python/runtime中的stub文件。

google_appengine/google/appengine/tools/devappserver2/python/runtime/stubs.py

发件人:

    def fake_uname():

      """Fake version of os.uname."""

      return ('Linux', '', '', '', '')

收件人:

    def fake_uname():
      """Fake version of os.uname."""
      return ('Linux', 'local', '19', 'Darwin Kernel Version 19', 'x86_64')

这不是一个很好的长期解决方案,因为对gcloud工具链的更新可能会消除这些更改。

最新更新