Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'escape_forward_slashes' is an invalid keyword argument for this function, when loading SpaCy 3.0 model (Python 3.10) #83

Open
kkoehncke opened this issue Jan 26, 2023 · 4 comments

Comments

@kkoehncke
Copy link

When using Python 3.10.8, getting following error:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/confection/__init__.py", line 495, in try_dump_json
    return srsly.json_dumps(value)
  File "/opt/conda/lib/python3.10/site-packages/srsly/_json_api.py", line 26, in json_dumps
    result = ujson.dumps(data, indent=indent, escape_forward_slashes=False)
TypeError: 'escape_forward_slashes' is an invalid keyword argument for this function

The above exception was the direct cause of the following exception:

 File "/app/ML/util/nlputil.py", line 35, in load_spacy_tokenizer
    nlp = spacy.load("en_core_web_sm", disable=disable)
  File "/opt/conda/lib/python3.10/site-packages/spacy/__init__.py", line 54, in load
    return util.load_model(
  File "/opt/conda/lib/python3.10/site-packages/spacy/util.py", line 432, in load_model
    return load_model_from_package(name, **kwargs)  # type: ignore[arg-type]
  File "/opt/conda/lib/python3.10/site-packages/spacy/util.py", line 468, 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/lib/python3.10/site-packages/en_core_web_sm/__init__.py", line 10, in load
    return load_model_from_init_py(__file__, **overrides)
  File "/opt/conda/lib/python3.10/site-packages/spacy/util.py", line 649, in load_model_from_init_py
    return load_model_from_path(
  File "/opt/conda/lib/python3.10/site-packages/spacy/util.py", line 506, in load_model_from_path
    nlp = load_model_from_config(
  File "/opt/conda/lib/python3.10/site-packages/spacy/util.py", line 554, in load_model_from_config
    nlp = lang_cls.from_config(
  File "/opt/conda/lib/python3.10/site-packages/spacy/language.py", line 1781, in from_config
    interpolated = filled.interpolate() if not filled.is_interpolated else filled
  File "/opt/conda/lib/python3.10/site-packages/confection/__init__.py", line 196, in interpolate
    return Config().from_str(self.to_str())
  File "/opt/conda/lib/python3.10/site-packages/confection/__init__.py", line 419, in to_str
    flattened.set(section_name, key, try_dump_json(value, node))
  File "/opt/conda/lib/python3.10/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.
{'train': None, 'dev': None, 'vectors': None, 'init_tok2vec': None}

Has anyone seen this error before?

@polm
Copy link
Contributor

polm commented Jan 30, 2023

We have not seen that error before.

What code were you using that caused it, and what version of srsly are you using?

It looks like you have a mismatch between ujson and srsly, but that shouldn't happen because srsly uses a vendored ujson.

@polm
Copy link
Contributor

polm commented Feb 2, 2023

Closing due to lack of reply, but please feel free to let us know if this is still an issue for you.

@polm polm closed this as completed Feb 2, 2023
@zafercavdar
Copy link

zafercavdar commented Mar 24, 2023

@polm I'm using Spacy 3.5.1 on Python 3.8.15 and experiencing the same issue. srsly version is 2.4.6. OS is Debian 10 Buster. My system had ujson installed, I tried uninstalling it but it didn't solve the issue.

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.

@wjun0830
Copy link

I also have the same problem
with spacy 3.7.1 python 3.7.10

@svlandeg svlandeg reopened this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants