# Buggy code
def create_post(self, path, **kw):
    """Create a new post."""
    if flag is None:
        req_missing(["ipython[notebook]>=2.0.0"], "build this site (compile ipynb)")
    content = kw.pop("content", None)
    onefile = kw.pop("onefile", False)
    kernel = kw.pop("ipython_kernel", None)
    # is_page is not needed to create the file
    kw.pop("is_page", False)

    metadata = {}
    metadata.update(self.default_metadata)
    metadata.update(kw)

    makedirs(os.path.dirname(path))

    if content.startswith("{"):
        # imported .ipynb file, guaranteed to start with "{" because it’s JSON.
        nb = nbformat.reads(content, current_nbformat)
    else:
        if ipy_modern:
            nb = nbformat.v4.new_notebook()
            nb["cells"] = [nbformat.v4.new_markdown_cell(content)]
        else:
            nb = nbformat.new_notebook()
            nb["worksheets"] = [
                nbformat.new_worksheet(
                    cells=[nbformat.new_text_cell("markdown", [content])]
                )
            ]

        if kernelspec is not None:
            if kernel is None:
                kernel = self.default_kernel
                self.logger.notice(
                    'No kernel specified, assuming "{0}".'.format(kernel)
                )

            IPYNB_KERNELS = {}
            ksm = kernelspec.KernelSpecManager()
            for k in ksm.find_kernel_specs():
                IPYNB_KERNELS[k] = ksm.get_kernel_spec(k).to_dict()
                IPYNB_KERNELS[k]["name"] = k
                del IPYNB_KERNELS[k]["argv"]

            if kernel not in IPYNB_KERNELS:
                self.logger.error(
                    'Unknown kernel "{0}". Maybe you mispelled it?'.format(kernel)
                )
                self.logger.info(
                    "Available kernels: {0}".format(", ".join(sorted(IPYNB_KERNELS)))
                )
                raise Exception('Unknown kernel "{0}"'.format(kernel))

            nb["metadata"]["kernelspec"] = IPYNB_KERNELS[kernel]
        else:
            # Older IPython versions don’t need kernelspecs.
            pass

    if onefile:
        nb["metadata"]["nikola"] = metadata

    with io.open(path, "w+", encoding="utf8") as fd:
        if ipy_modern:
            nbformat.write(nb, fd, 4)
        else:
            nbformat.write(nb, fd, "ipynb")


# Traceback (AttributeError)
[2017-04-23T16:38:22Z] ERROR: yapsy: Unable to import plugin: /usr/lib/python3.5/site-packages/nikola/plugins/compile/ipynb
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/yapsy/PluginManager.py", line 488, in loadPlugins
candidate_module = imp.load_module(plugin_module_name,plugin_file,candidate_filepath+".py",("py","r",imp.PY_SOURCE))
File "/usr/lib64/python3.5/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/usr/lib64/python3.5/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/usr/lib/python3.5/site-packages/nikola/plugins/compile/ipynb.py", line 36, in <module>
from nbconvert.exporters import HTMLExporter
File "/usr/lib/python3.5/site-packages/nbconvert/__init__.py", line 4, in <module>
from .exporters import *
File "/usr/lib/python3.5/site-packages/nbconvert/exporters/__init__.py", line 1, in <module>
from .base import (export, get_exporter,
File "/usr/lib/python3.5/site-packages/nbconvert/exporters/base.py", line 16, in <module>
from .exporter import Exporter
File "/usr/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 47, in <module>
class Exporter(LoggingConfigurable):
File "/usr/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 55, in Exporter
help="Extension of the file that should be written to disk"
AttributeError: 'FilenameExtension' object has no attribute 'tag'
Nikola v7.8.4

# Fixed code
def create_post(self, path, **kw):
    """Create a new post."""
    self._req_missing_ipynb()
    content = kw.pop("content", None)
    onefile = kw.pop("onefile", False)
    kernel = kw.pop("ipython_kernel", None)
    # is_page is not needed to create the file
    kw.pop("is_page", False)

    metadata = {}
    metadata.update(self.default_metadata)
    metadata.update(kw)

    makedirs(os.path.dirname(path))

    if content.startswith("{"):
        # imported .ipynb file, guaranteed to start with "{" because it’s JSON.
        nb = nbformat.reads(content, current_nbformat)
    else:
        nb = nbformat.v4.new_notebook()
        nb["cells"] = [nbformat.v4.new_markdown_cell(content)]

        if kernelspec is not None:
            if kernel is None:
                kernel = self.default_kernel
                self.logger.notice(
                    'No kernel specified, assuming "{0}".'.format(kernel)
                )

            IPYNB_KERNELS = {}
            ksm = kernelspec.KernelSpecManager()
            for k in ksm.find_kernel_specs():
                IPYNB_KERNELS[k] = ksm.get_kernel_spec(k).to_dict()
                IPYNB_KERNELS[k]["name"] = k
                del IPYNB_KERNELS[k]["argv"]

            if kernel not in IPYNB_KERNELS:
                self.logger.error(
                    'Unknown kernel "{0}". Maybe you mispelled it?'.format(kernel)
                )
                self.logger.info(
                    "Available kernels: {0}".format(", ".join(sorted(IPYNB_KERNELS)))
                )
                raise Exception('Unknown kernel "{0}"'.format(kernel))

            nb["metadata"]["kernelspec"] = IPYNB_KERNELS[kernel]
        else:
            # Older IPython versions don’t need kernelspecs.
            pass

    if onefile:
        nb["metadata"]["nikola"] = metadata

    with io.open(path, "w+", encoding="utf8") as fd:
        nbformat.write(nb, fd, 4)