Jupyter_contrib_nbextensions: No module named EmbedPostProcessor

Created on 6 Oct 2016  路  10Comments  路  Source: ipython-contrib/jupyter_contrib_nbextensions

when trying to call jupyter nbextension, the following error message occurs:

[NbConvertApp] WARNING | Error loading config file: jupyter_nbconvert_config
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/ipython_genutils/importstring.py", line 33, in import_item
    pak = getattr(module, obj)
AttributeError: module 'jupyter_contrib_nbextensions.nbconvert_support' has no attribute 'EmbedPostProcessor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/jupyter_core/application.py", line 202, in load_config_file
    path=path
  File "<decorator-gen-5>", line 2, in load_config_file
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py", line 603, in load_config_file
    self.update_config(new_config)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/configurable.py", line 198, in update_config
    self._load_config(config)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/configurable.py", line 168, in _load_config
    warn(msg)
  File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__
    next(self.gen)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py", line 1129, in hold_trait_notifications
    self.notify_change(change)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py", line 1174, in notify_change
    c(change)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py", line 702, in __call__
    self.cb(change.name, change.old, change.new)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/nbconvertapp.py", line 213, in _postprocessor_class_changed
    self.postprocessor_factory = import_item(new)
  File "/usr/local/lib/python3.5/dist-packages/ipython_genutils/importstring.py", line 35, in import_item
    raise ImportError('No module named %s' % obj)
ImportError: No module named EmbedPostProcessor
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/ipython_genutils/importstring.py", line 33, in import_item
    pak = getattr(module, obj)
AttributeError: module 'jupyter_contrib_nbextensions.nbconvert_support' has no attribute 'EmbedPostProcessor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-nbconvert", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/nbconvertapp.py", line 237, in initialize
    self.init_postprocessor()
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/nbconvertapp.py", line 286, in init_postprocessor
    self.postprocessor_class)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/nbconvertapp.py", line 213, in _postprocessor_class_changed
    self.postprocessor_factory = import_item(new)
  File "/usr/local/lib/python3.5/dist-packages/ipython_genutils/importstring.py", line 35, in import_item
    raise ImportError('No module named %s' % obj)
ImportError: No module named EmbedPostProcessor

Exporting to .html through the browser interface works fine, but calling nbconvert causes this issue. Any help is much appreciated!

OS: Ubuntu 16.04 LTS
jupyter version 4.2.0
jupyter-contrib-nbextension version 0.2.0

Most helpful comment

I experienced the same thing when running jupyter nbconvert --to python mynotebook.ipynb:

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/bin/jupyter-nbconvert", line 6, in <module>
    sys.exit(main())
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 652, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 237, in initialize
    self.init_postprocessor()
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 286, in init_postprocessor
    self.postprocessor_class)
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 213, in _postprocessor_class_changed
    self.postprocessor_factory = import_item(new)
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/ipython_genutils/importstring.py", line 35, in import_item
    raise ImportError('No module named %s' % obj)
ImportError: No module named EmbedPostProcessor

All 10 comments

If you upgraded from an older version of the notebooks extensions, you can try
executing the command jupyter contrib nbextension migrate

Otherwise, can you try doing
import jupyter_contrib_nbextensions.nbconvert_support.post_embedhtml
in IPython?

Thanks for the quick response. Unfortunately the migrate command didn't seem to fix it.

With iPython in the terminal:

~$ ipython
Python 3.5.2 (default, Sep 10 2016, 08:21:44) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import jupyter_contrib_nbextensions.nbconvert_support.post_embedhtml
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-7b12130a4b8e> in <module>()
----> 1 import jupyter_contrib_nbextensions.nbconvert_support.post_embedhtml

ImportError: No module named 'jupyter_contrib_nbextensions.nbconvert_support.post_embedhtml'

I experienced the same thing when running jupyter nbconvert --to python mynotebook.ipynb:

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/bin/jupyter-nbconvert", line 6, in <module>
    sys.exit(main())
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 652, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 237, in initialize
    self.init_postprocessor()
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 286, in init_postprocessor
    self.postprocessor_class)
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 213, in _postprocessor_class_changed
    self.postprocessor_factory = import_item(new)
  File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/ipython_genutils/importstring.py", line 35, in import_item
    raise ImportError('No module named %s' % obj)
ImportError: No module named EmbedPostProcessor

I've fixed this by editing ~/.jupyter/jupyter_nbconvert_config.json
and removing this line:
"postprocessor_class": "jupyter_contrib_nbextensions.nbconvert_support.EmbedPostProcessor"

I think this is a result of the rename of embed postprocessor class, we should perhaps add the rename to our migrate script, as with the renamed yapf_ext->code_prettify in #786

Yes. I also had this issue.

Soedjais's way fixed this problem for me. However, if you run jupyter notebook under Windows, the configuration file jupyter_nbconvert_config.json might not be in the "user/.jupyter" directory.
Run

jupyter-nbconvert --to html yourfile.ipynb --log-level=DEBUG

to see the log and it will tell you where you can find the file that really affects the conversion. In my case, it's in "c:\ProgramData" which is an invisible system directory. This directory would not be removed even if you uninstall the Anaconda.

if you run jupyter notebook under Windows, the configuration file jupyter_nbconvert_config.json might not be in the "user/.jupyter" directory

Different platforms have different jupyter directories, and even on single platform there are at least three alternatives (per-user, python sys-prefix, and system-wide). For the per-user directories on your system, use

jupyter --config-dir
jupyter --data-dir

Which does indeed give ~/.jupyter for me on Windows 8.1. However, if you've installed not in the per-user config, you'll want an exhaustive list of jupyter directories, for which you can use

jupyter --paths

As @ccchiang notes, running an nbconvert command with debug tell you which files are actually loaded. The Windows C:\ProgramData\jupyter path is the system-level jupyter directory, so presumably you made a system-wide install (i.e. no --user or --sys-prefix flags) for that to have happened.

I had to remove "postprocessor_class": "jupyter_contrib_nbextensions.nbconvert_support.EmbedPostProcessor" from the default config file in the anaconda folder to fix this issue:

cat /home/bnijholt/anaconda3/etc/jupyter/jupyter_nbconvert_config.json
{
  "NbConvertApp": {
    "postprocessor_class": "jupyter_contrib_nbextensions.nbconvert_support.EmbedPostProcessor"
  },
  "Exporter": {
    "template_path": [
      ".",
      "/home/bnijholt/anaconda3/lib/python3.5/site-packages/jupyter_contrib_nbextensions/templates"
    ],
    "preprocessors": [
      "jupyter_contrib_nbextensions.nbconvert_support.CodeFoldingPreprocessor",
      "jupyter_contrib_nbextensions.nbconvert_support.PyMarkdownPreprocessor"
    ]
  },
  "version": 1
}

If you upgraded from an older version of the notebooks extensions, you can try
executing the command jupyter contrib nbextension migrate

That was the fix for me!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

metabolinguistics picture metabolinguistics  路  4Comments

slowkow picture slowkow  路  3Comments

Time1ess picture Time1ess  路  7Comments

vinniec picture vinniec  路  7Comments

guerreroda picture guerreroda  路  5Comments