Notebook: nbconvert failed: validate() got an unexpected keyword argument 'relax_add_props'

Created on 4 Oct 2017  路  5Comments  路  Source: jupyter/notebook

I tried to download the py in pdf format but I have the error "nbconvert failed: validate() got an unexpected keyword argument 'relax_add_props'". And I tried to download it as .py or .tex, none of them works and give back the same error.

[E 12:58:14.833 NotebookApp] nbconvert failed: validate() got an unexpected keyword argument 'relax_add_props'
    Traceback (most recent call last):
      File "/Users/Wanhui/anaconda3/lib/python3.6/site-packages/notebook/nbconvert/handlers.py", line 104, in get
        "config_dir": self.application.settings['config_dir'],
      File "/Users/Wanhui/anaconda3/lib/python3.6/site-packages/nbconvert/exporters/script.py", line 49, in from_notebook_node
        return exporter.from_notebook_node(nb, resources, **kw)
      File "/Users/Wanhui/anaconda3/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 280, in from_notebook_node
        nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
      File "/Users/Wanhui/anaconda3/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 134, in from_notebook_node
        nb_copy, resources = self._preprocess(nb_copy, resources)
      File "/Users/Wanhui/anaconda3/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 313, in _preprocess
        nbformat.validate(nbc, relax_add_props=True)
    TypeError: validate() got an unexpected keyword argument 'relax_add_props'

How to solve it? I already installed MacTex on my mac.

Waiting for Author Environment

Most helpful comment

you need to update your version of nbformat.

pip install -U nbformat

All 5 comments

you need to update your version of nbformat.

pip install -U nbformat

I have the same despite nbformat being installed.

Update: Hmm... I tried to debug a bit. It seems that ipython is importing wrong nbformat, see:

(conda-forge) rskolasinski@petrucci:some_project> conda list nbformat
# packages in environment at /home/arch/miniconda3/envs/conda-forge:
#
nbformat                  4.4.0                    py36_0    conda-forge
(conda-forge) rskolasinski@petrucci:some_project> which ipython
/home/arch/miniconda3/envs/conda-forge/bin/ipython
(conda-forge) rskolasinski@petrucci:some_project> ipython
Python 3.6.3 | packaged by conda-forge | (default, Nov  4 2017, 10:10:56) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import nbformat

In [2]: nbformat.__version__
Out[2]: '4.3.0'

In [3]: nbformat.__file__
Out[3]: '/home/arch/.local/lib/python3.6/site-packages/nbformat/__init__.py'

update: for some reasons conda leaves ~/.local/lib in the path

rskolasinski@petrucci:~> reconda
added conda to path: /home/arch/miniconda3/bin
rskolasinski@petrucci:~> ipython
iPython 3.6.2 |Anaconda, Inc.| (default, Sep 30 2017, 18:42:57) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sys

In [2]: sys.path
Out[2]: 
['',
 '/home/arch/miniconda3/bin',
 '/home/arch/miniconda3/lib/python36.zip',
 '/home/arch/miniconda3/lib/python3.6',
 '/home/arch/miniconda3/lib/python3.6/lib-dynload',
 '/home/arch/.local/lib/python3.6/site-packages',
 '/home/arch/miniconda3/lib/python3.6/site-packages',
 '/home/arch/miniconda3/lib/python3.6/site-packages/IPython/extensions',
 '/home/arch/.ipython']

In [3]: 

Ok. It's conda issue/feature. Described in https://github.com/conda/conda/issues/448 and in https://github.com/conda/conda/issues/6018.

Solution for me was export PYTHONNOUSERSITE=True.

@fash97 To avoid this error make sure that you have nbformat==4.4.

@RafalSkolasinski
OK, I figured out how to update nbformat (conda update nbformat), but do not know where to set export PYTHONNOUSERSITE=True.

It looks like publishing notebooks to pdf is not for people like me who don't want to dive down the rabbit hole of the inner workings of Jupyter, python, conda, pandoc, etc. I'll try again in a year or two, and see if it just works out of the box. Maybe if I did a fresh install of Anaconda... maybe there are some online tools...

Edit-- Thank you for diving down the rabbit hole and finding solutions and solving problems for people like me.

but do not know where to set export PYTHONNOUSERSITE=True.

You can set it in your .bashrc.

You can try making fresh install of Anaconda and removing completely ~/.local/lib/pythonX.Y directory. Then it should only be using conda's installation

Was this page helpful?
0 / 5 - 0 ratings