如何修复 Google App Engine dev_appserver.py: watcher_ignore_re flag "is not JSON serializable" 错误?
How can I fix Google App Engine dev_appserver.py: watcher_ignore_re flag "is not JSON serializable" error?
我想首先指出我尝试了每个答案 。 None 其中似乎解决了这个问题,这个问题已经有一段时间了。
问题
我想 运行 dev_appserver.py 同时将某些文件添加到观察者的忽略列表;这意味着 skip_files 是不可能的,因为此选项将它们从服务器读取中移除。
当我 运行 dev_appserver.py 没有 --watcher_ignore_re 标志时,除了文件监视外,一切正常。当我使用标志执行 运行 时,出现以下错误:
INFO 2021-11-02 13:54:50,100 devappserver2.py:309] Skipping SDK update check.
Traceback (most recent call last):
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 109, in <module>
_run_file(__file__, globals())
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in _run_file
_execfile(_PATHS.script_file(script_name), globals_)
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 83, in _execfile
execfile(fn, scope)
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 635, in <module>
main()
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 623, in main
dev_server.start(options)
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 356, in start
java_major_version=self.java_major_version
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/metrics.py", line 185, in Start
self._cmd_args = json.dumps(vars(cmd_args)) if cmd_args else None
File "/usr/lib/python2.7/json/__init__.py", line 244, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <_sre.SRE_Pattern object at 0x7f720c625240> is not JSON serializable
我试过不同的版本都没有成功:
- GCloud 361.0.0/362.0.0/357.0.0/240.0.0/220.0.0/200.0.0
- Python 2.7.18/3.9.7
我还在观察者标志上尝试了不同的字符串值:
- ""
- ''
- ".css"
- "*.css"
- ".*\css"
- '.css'
- '*.css'
- '.*\css'
- 等等
我知道问题不在于字符串的构成方式(至少看起来不像)。而且不同的版本也无济于事。
我的同事没有这个问题,他们在 MacOS 上使用我在此处列出的不同版本。我目前在 arch Linux,但我 运行 在我的 mac 上也遇到了完全相同的问题。
我还在 ~/.zshrc
文件中添加了 export CLOUDSDK_PYTHON=python2.7
。
原来这毕竟是重复的。我错过了一条有解决方案的评论。这个:
It looks like it is an issue with the google analytics code built into dev_appserver2 (google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py on or around line 316). It wants to send all of your command line options to google analytics. If you remove the analytics client id by adding the command line option --google_analytics_client_id= (note: '=' without any following value) the appserver won't call the google analytics code where it is trying to JSON serialize an SRE object and failing.
简而言之,对于任何经过这里的人,只需添加此选项,只需添加此选项:
--google_analytics_client_id=
没有值。
我想首先指出我尝试了每个答案
问题
我想 运行 dev_appserver.py 同时将某些文件添加到观察者的忽略列表;这意味着 skip_files 是不可能的,因为此选项将它们从服务器读取中移除。
当我 运行 dev_appserver.py 没有 --watcher_ignore_re 标志时,除了文件监视外,一切正常。当我使用标志执行 运行 时,出现以下错误:
INFO 2021-11-02 13:54:50,100 devappserver2.py:309] Skipping SDK update check.
Traceback (most recent call last):
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 109, in <module>
_run_file(__file__, globals())
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in _run_file
_execfile(_PATHS.script_file(script_name), globals_)
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 83, in _execfile
execfile(fn, scope)
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 635, in <module>
main()
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 623, in main
dev_server.start(options)
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 356, in start
java_major_version=self.java_major_version
File "/home/USERNAME/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/metrics.py", line 185, in Start
self._cmd_args = json.dumps(vars(cmd_args)) if cmd_args else None
File "/usr/lib/python2.7/json/__init__.py", line 244, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <_sre.SRE_Pattern object at 0x7f720c625240> is not JSON serializable
我试过不同的版本都没有成功:
- GCloud 361.0.0/362.0.0/357.0.0/240.0.0/220.0.0/200.0.0
- Python 2.7.18/3.9.7
我还在观察者标志上尝试了不同的字符串值:
- ""
- ''
- ".css"
- "*.css"
- ".*\css"
- '.css'
- '*.css'
- '.*\css'
- 等等
我知道问题不在于字符串的构成方式(至少看起来不像)。而且不同的版本也无济于事。
我的同事没有这个问题,他们在 MacOS 上使用我在此处列出的不同版本。我目前在 arch Linux,但我 运行 在我的 mac 上也遇到了完全相同的问题。
我还在 ~/.zshrc
文件中添加了 export CLOUDSDK_PYTHON=python2.7
。
原来这毕竟是重复的。我错过了一条有解决方案的评论。这个:
It looks like it is an issue with the google analytics code built into dev_appserver2 (google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py on or around line 316). It wants to send all of your command line options to google analytics. If you remove the analytics client id by adding the command line option --google_analytics_client_id= (note: '=' without any following value) the appserver won't call the google analytics code where it is trying to JSON serialize an SRE object and failing.
简而言之,对于任何经过这里的人,只需添加此选项,只需添加此选项:
--google_analytics_client_id=
没有值。