You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: 'escape_forward_slashes' is an invalid keyword argument for this function, when loading SpaCy 3.5 model (Python 3.8) #89
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.
From the two reports, this sounds like something can go wrong with the srsly installation in conda. I'm not sure whether it's the installation itself or the srsly package.
Actually I didn't use conda too install spacy or srsly. I have a base environment and I'm using poetry to manage all packages. Poetry doesn't create a new environment, instead uses conda's base env. I'm trying with conda now. (btw, spacy 3.3.1 on python 3.7 was working fine. This problem started with python 3.8. Now it doesn't matter whether I use spacy 3.3.1 or 3.5.1, both fails with the same error message.
And if you create a new conda env and reinstall your dependencies with poetry, what does conda list show?
I don't know for sure, but my best guess is that different install steps have installed srsly and something didn't get uninstalled or upgraded cleanly or there's an incompatible mix of pip and conda packages.
If you want to keep the current base environment, you might try being really sure that you've uninstalled srsly before working with your project:
conda list doesn't show srsly before I install spacy but it has ujson 5.7.0 installed before spacy was installed. I uninstalled it but again, the same error. The same code works fine on MacOS env, Python3.8 in Docker but doesn't work on Debian 10 conda environment. Does this repository depend on Cython or GCC version? How do you run C code in Python environment?
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.
It really sounds like this might be a problem with a particular srsly package or a particular combination of pip/conda packages. You shouldn't need to hack source files in srsly for things to work, and srsly should be using its own vendored ujson, so this is all very unexpected and confusing.
Can anyone provide more details about their environment, in particular the output of conda list that shows more details about the conda packages. For example, the output for srsly and ujson from conda list could look like this:
It really sounds like this might be a problem with a particular srsly package or a particular combination of pip/conda packages. You shouldn't need to hack source files in srsly for things to work, and srsly should be using its own vendored ujson, so this is all very unexpected and confusing.
Can anyone provide more details about their environment, in particular the output of conda list that shows more details about the conda packages. For example, the output for srsly and ujson from conda list could look like this:
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}
The output of the conda list command:
srsly 2.4.5 pypi_0 pypi
ujson 5.7.0 pypi_0 pypi
I tried to install the 2.4.6 version, but it didn't work either.
Thanks for the info! Several of us have tried to reproduce this in a conda environment with no luck, so I'm afraid we're still not quite sure what's going on.
As far as I know the version of ujson vendored in srsly has always included escape_forward_slashes.
Thanks, I could recreate the same conda env but I'm afraid I still couldn't reproduce this error.
The next time it happens, could you check if changing your current working directory makes a difference? It's a bit of stab in the dark, but maybe there's a particular local python file/module that's affecting this?
Thanks, I could recreate the same conda env but I'm afraid I still couldn't reproduce this error.
The next time it happens, could you check if changing your current working directory makes a difference? It's a bit of stab in the dark, but maybe there's a particular local python file/module that's affecting this?
Thanks for your reply. How do I change my current working directory? I'm using WSL 2 and ubuntu 18.04 inside my VS Code. I'm thinking about re-create my conda environment and check if that's the problem. What do you think?
Guys I have faced with same problem when I tried to run app inside docker. So I did some research and I think the problem is in ffmpeg.
Try to run:
apt -y update && apt -y install ffmpeg
This command fixed issue for me. Good luck
Thanks for the note! I can't figure out how ffmpeg would affect ujson, but maybe this indicates that the problem is somehow related to system libraries with the same symbols and not problems with the python module/packages directly. Would it be possible for you to share the basic configuration from your Dockerfile?
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.
This is what worked for me as well. Here's how I did it with a few commands:
SITE_PACKAGES=$( pip show srsly | grep Location | sed 's/^Location: //g')
JSON_API_FILE=$SITE_PACKAGES/srsly/_json_api.py
sed -i 's/, escape_forward_slashes=False//g'$JSON_API_FILE
Activity
adrianeboyd commentedon Mar 27, 2023
From the two reports, this sounds like something can go wrong with the
srslyinstallation in conda. I'm not sure whether it's the installation itself or thesrslypackage.What does
conda listshow forsrsly?If you create a brand new conda env and run only:
can you load the model in the new env?
zafercavdar commentedon Mar 27, 2023
Actually I didn't use conda too install spacy or srsly. I have a base environment and I'm using poetry to manage all packages. Poetry doesn't create a new environment, instead uses conda's base env. I'm trying with conda now. (btw, spacy 3.3.1 on python 3.7 was working fine. This problem started with python 3.8. Now it doesn't matter whether I use spacy 3.3.1 or 3.5.1, both fails with the same error message.
adrianeboyd commentedon Mar 28, 2023
What does
conda listshow?And if you create a new conda env and reinstall your dependencies with poetry, what does
conda listshow?I don't know for sure, but my best guess is that different install steps have installed srsly and something didn't get uninstalled or upgraded cleanly or there's an incompatible mix of pip and conda packages.
If you want to keep the current base environment, you might try being really sure that you've uninstalled
srslybefore working with your project:and then start your project install (however you install spacy) again?
zafercavdar commentedon Apr 4, 2023
conda listdoesn't showsrslybefore I install spacy but it hasujson 5.7.0installed before spacy was installed. I uninstalled it but again, the same error. The same code works fine on MacOS env, Python3.8 in Docker but doesn't work on Debian 10 conda environment. Does this repository depend on Cython or GCC version? How do you run C code in Python environment?adrianeboyd commentedon Apr 5, 2023
Please copy and paste the exact output of
conda listin the environment where this problem happens.vishhvak commentedon Apr 13, 2023
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.
adrianeboyd commentedon Apr 18, 2023
It really sounds like this might be a problem with a particular
srslypackage or a particular combination of pip/conda packages. You shouldn't need to hack source files insrslyfor things to work, andsrslyshould be using its own vendored ujson, so this is all very unexpected and confusing.Can anyone provide more details about their environment, in particular the output of
conda listthat shows more details about the conda packages. For example, the output forsrslyandujsonfromconda listcould look like this:nhm-7 commentedon Apr 23, 2023
I got the same error:
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}
The output of the
conda listcommand:I tried to install the 2.4.6 version, but it didn't work either.
Also, I have the following libraries installed:
adrianeboyd commentedon Apr 28, 2023
Thanks for the info! Several of us have tried to reproduce this in a conda environment with no luck, so I'm afraid we're still not quite sure what's going on.
As far as I know the version of ujson vendored in
srslyhas always includedescape_forward_slashes.Can you try running the
srslytest suite?nhm-7 commentedon May 3, 2023
Done! this is the output after running the tests:

adrianeboyd commentedon May 4, 2023
Thanks! So the
srslyinstall looks fine and the problem must be somewhere else.What about the confection tests:
And if those pass, then the spacy tests:
And the
conda listoutput forconfectionandspacy?BennoKrojer commentedon May 5, 2023
I am having the exact same issue right now! Will do the test you mentioned for confection
adrianeboyd commentedon May 5, 2023
I hope we can get to the bottom of this. Any details about your environment and the code you're running would be appreciated!
adrianeboyd commentedon May 5, 2023
If there's nothing confidential about your environment, maybe the output of
conda env exportcould help us reproduce this?nhm-7 commentedon May 6, 2023
I've got this error.
conda env export:
Guys, I don't know why, but now it's working. Seriously, I don't know what is happening. I mean, I run only these commands:
Then, the conda export. And now I try to run my experiments and everything is working as usual.
nhm-7 commentedon May 8, 2023
Hi again guys, it's failing again. I've just turned on my computer and run again my experiments, here's again the traceback:
adrianeboyd commentedon May 17, 2023
Thanks, I could recreate the same conda env but I'm afraid I still couldn't reproduce this error.
The next time it happens, could you check if changing your current working directory makes a difference? It's a bit of stab in the dark, but maybe there's a particular local python file/module that's affecting this?
nhm-7 commentedon May 17, 2023
Thanks for your reply. How do I change my current working directory? I'm using WSL 2 and ubuntu 18.04 inside my VS Code. I'm thinking about re-create my conda environment and check if that's the problem. What do you think?
AdriianSWSY commentedon Jun 4, 2023
Guys I have faced with same problem when I tried to run app inside docker. So I did some research and I think the problem is in ffmpeg.
Try to run:
apt -y update && apt -y install ffmpeg
This command fixed issue for me. Good luck
adrianeboyd commentedon Jun 5, 2023
Thanks for the note! I can't figure out how ffmpeg would affect ujson, but maybe this indicates that the problem is somehow related to system libraries with the same symbols and not problems with the python module/packages directly. Would it be possible for you to share the basic configuration from your Dockerfile?
EarningsCall commentedon Aug 12, 2023
This is what worked for me as well. Here's how I did it with a few commands: