srsly: TypeError: 'escape_forward_slashes' is an invalid keyword argument for this function, when loading SpaCy 3.5 model (Python 3.8)
Since https://github.com/explosion/srsly/issues/83 is closed, I’m opening it again.
- I’m using Spacy 3.5.1 on Python 3.8.15 and experiencing the same issue.
srslyversion is 2.4.6. - OS is Debian 10 Buster. My system had
ujsoninstalled, I tried uninstalling it but it didn’t solve the issue. - Spacy 3.3.1,
srrsly=2.4.3in the same environment also gives the same error.
The code to reproduce:
bash:
python3 -m spacy download it_core_news_sm
python3:
import spacy
spacy.load("it_core_news_sm")
The full trace
nlp = spacy.load(model_name, exclude=excluded_pipes)
File "/opt/conda/default/lib/python3.8/site-packages/spacy/__init__.py", line 54, in load
return util.load_model(
File "/opt/conda/default/lib/python3.8/site-packages/spacy/util.py", line 442, in load_model
return load_model_from_package(name, **kwargs) # type: ignore[arg-type]
File "/opt/conda/default/lib/python3.8/site-packages/spacy/util.py", line 478, in load_model_from_package
return cls.load(vocab=vocab, disable=disable, enable=enable, exclude=exclude, config=config) # type: ignore[attr-defined]
File "/opt/conda/default/lib/python3.8/site-packages/it_core_news_sm/__init__.py", line 10, in load
return load_model_from_init_py(__file__, **overrides)
File "/opt/conda/default/lib/python3.8/site-packages/spacy/util.py", line 659, in load_model_from_init_py
return load_model_from_path(
File "/opt/conda/default/lib/python3.8/site-packages/spacy/util.py", line 516, in load_model_from_path
nlp = load_model_from_config(
File "/opt/conda/default/lib/python3.8/site-packages/spacy/util.py", line 564, in load_model_from_config
nlp = lang_cls.from_config(
File "/opt/conda/default/lib/python3.8/site-packages/spacy/language.py", line 1781, in from_config
interpolated = filled.interpolate() if not filled.is_interpolated else filled
File "/opt/conda/default/lib/python3.8/site-packages/confection/__init__.py", line 196, in interpolate
return Config().from_str(self.to_str())
File "/opt/conda/default/lib/python3.8/site-packages/confection/__init__.py", line 419, in to_str
flattened.set(section_name, key, try_dump_json(value, node))
File "/opt/conda/default/lib/python3.8/site-packages/confection/__init__.py", line 503, in try_dump_json
raise ConfigValidationError(config=data, desc=err_msg) from e
confection.ConfigValidationError:
Config validation error
Couldn't serialize config value of type <class 'NoneType'>: 'escape_forward_slashes' is an invalid keyword argument for this function. Make sure all values in your config are JSON-serializable. If you want to include Python objects, use a registered function that returns the object instead.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 2
- Comments: 21
A hack that worked for me was to just edit the _json_api.py file under srsly to not have the escape_forward_slashes keyword (i.e remove it from the line with the ujson.dumps() function call). If anyone needs a quick fix that doesn’t use that keyword for their functionality, feel free to edit the file as a workaround lol.
I hope we can get to the bottom of this. Any details about your environment and the code you’re running would be appreciated!