OSX dev_appserver.py 文件无法访问:'/System/Library/CoreServices/SystemVersion.plist'



我在2天前完成了gcloud components update,并在运行dev_appserver.py

时开始遇到此错误
(venv) myusername@mymachine:~/projects/myproject$ dev_appserver.py ./ --host 0.0.0.0 --port 8002 --enable_console --env_var GCS_TOKEN=ya29........YJDQAnp772B0
INFO     2019-03-13 23:45:31,205 devappserver2.py:278] Skipping SDK update check.
INFO     2019-03-13 23:45:31,268 api_server.py:275] Starting API server at: http://localhost:64587
INFO     2019-03-13 23:45:31,319 dispatcher.py:256] Starting module "default" running at: http://0.0.0.0:8002
INFO     2019-03-13 23:45:31,325 admin_server.py:150] Starting admin server at: http://localhost:8000
/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:182: UserWarning: There are too many files in your application for changes in all of them to be monitored. You may have to restart the development server to see some changes to your files.
  'There are too many files in your application for '
INFO     2019-03-13 23:45:35,237 instance.py:294] Instance PID: 29760
appengine_config
requests.__version__ 2.21.0
Appengine config done
4
ERROR    2019-03-13 23:45:35,986 wsgi.py:263] 
Traceback (most recent call last):
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/Users/myusername/projects/myproject/main.py", line 34, in <module>
    from bp_includes.lib.error_handler import handle_error
  File "/Users/myusername/projects/myproject/bp_includes/lib/error_handler.py", line 15, in <module>
    from bp_includes.lib import jinja_bootstrap
  File "/Users/myusername/projects/myproject/bp_includes/lib/jinja_bootstrap.py", line 7, in <module>
    from src.handlers.utils import ordinal
  File "/Users/myusername/projects/myproject/src/handlers/utils.py", line 14, in <module>
    from lib.pytz.gae import pytz
  File "/Users/myusername/projects/myproject/lib/pytz/__init__.py", line 29, in <module>
    from pkg_resources import resource_stream
  File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 1022, in <module>
    class Environment(object):
  File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 1025, in Environment
    def __init__(self, search_path=None, platform=get_supported_platform(),
  File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 263, in get_supported_platform
    plat = get_build_platform()
  File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 472, in get_build_platform
INFO     2019-03-13 23:45:36,002 module.py:861] default: "GET /_ah/warmup HTTP/1.1" 500 -
    version = _macosx_vers()
  File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 439, in _macosx_vers
    version = platform.mac_ver()[0]
  File "/Users/myusername/projects/myproject/venv/lib/python2.7/platform.py", line 764, in mac_ver
    info = _mac_ver_xml()
  File "/Users/myusername/projects/myproject/venv/lib/python2.7/platform.py", line 741, in _mac_ver_xml
    pl = plistlib.readPlist(fn)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 75, in readPlist
    pathOrFile = open(pathOrFile)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/stubs.py", line 284, in __init__
    raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/System/Library/CoreServices/SystemVersion.plist'

我最初使用brew cask install google-cloud-sdk安装了GCloud,以防相关

看起来这个问题是在GCLOUD 238.0.0中引入的,可能是GCLOUD App Python Extensions 1.9.84。您可以使用以下方式降级GCLOUD至降低版本。

gcloud components update --version 237.0.0

我通过在appengine_config.py中进行以下操作使它起作用,但是我希望有人有更好的解决方案

try:
    from google.appengine.tools.devappserver2.python.runtime.stubs import FakeFile
    FakeFile._allowed_dirs.update(['/System/Library/CoreServices/'])    
except ImportError:
    pass

您可以删除安装要求的LIB文件夹,并重新安装它对我有用

pip install -t "lib" -r requirements.txt

相关内容

最新更新