Unable to export jupyter notebook to any other format using nbconvert - jupyter-notebook

I am using Python 3.8.5 on Windows 10. I installed Jupyterlab and it works correctly. However nbconvert does not. When I try to export notebook to any format, I get the following error in the terminal:
[W 16:14:06.733 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20200928161400 (::1) 8.46ms referer=http://localhost:8889/notebooks/tester1/testing_epr_py.ipynb
[I 16:14:07.066 NotebookApp] Kernel started: 1e1cd4f1-55e7-4583-b343-98ed9670e8f9, name: python3
[E 16:14:10.773 NotebookApp] Uncaught exception GET /nbconvert/html/tester1/testing_epr_py.ipynb?download=true (::1)
HTTPServerRequest(protocol='http', host='localhost:8889', method='GET', uri='/nbconvert/html/tester1/testing_epr_py.ipynb?download=true', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 535, in get
value = obj._trait_values[self.name]
KeyError: 'template_paths'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\tornado\web.py", line 1703, in _execute
result = await result
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\notebook\nbconvert\handlers.py", line 93, in get
exporter = get_exporter(format, config=self.config, log=self.log)
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\notebook\nbconvert\handlers.py", line 67, in get_exporter
Exporter = get_exporter(format)
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\nbconvert\exporters\base.py", line 102, in get_exporter
if getattr(exporter(config=config), 'enabled', True):
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\nbconvert\exporters\templateexporter.py", line 328, in __init__
super().__init__(config=config, **kw)
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\nbconvert\exporters\exporter.py", line 114, in __init__
self._init_preprocessors()
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\nbconvert\exporters\templateexporter.py", line 494, in _init_preprocessors
conf = self._get_conf()
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\nbconvert\exporters\templateexporter.py", line 510, in _get_conf
for path in map(Path, self.template_paths):
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 575, in __get__
return self.get(obj, cls)
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 538, in get
default = obj.trait_defaults(self.name)
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 1577, in trait_defaults
return self._get_trait_default_generator(names[0])(self)
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 975, in __call__
return self.func(*args, **kwargs)
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\nbconvert\exporters\templateexporter.py", line 521, in _template_paths
template_names = self.get_template_names()
File "C:\Users\draco.malfoy\AppData\Roaming\Python\Python38\site-packages\nbconvert\exporters\templateexporter.py", line 582, in get_template_names
raise ValueError('No template sub-directory with name %r found in the following paths:\n\t%s' % (base_template, paths))
ValueError: No template sub-directory with name 'lab' found in the following paths:
C:\Users\draco.malfoy\AppData\Roaming\jupyter
C:\Program Files\Python38\share\jupyter
C:\ProgramData\jupyter
I also tried to use nbconvert through command line but got the same error. nbconvert version is 6.0.6. Any help is greatly appreciated.

Copying files from "C:\Users\{username}\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\share\jupyter"
to "C:\ProgramData\jupyter" helped me solve this issue, kindly note that you will have to install Pandoc and MiKTex on Windows if you want to convert notebooks.

Related

Saltstack -> 'Pillar failed to render with the following messages'

On my FreeBSD I have a file packages.sls in the following path /usr/local/etc/salt/states
I'm getting the following error message when i do salt '*' state.apply packages :
freebsd:
Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Rendering SLS 'config' failed. Please see master log for details.
On the file master log i have the following details:
2022-06-02 10:05:12,222 [salt.roster :104 ][ERROR ][3425] Can't access roster for backend flat: Roster file "/usr/local/etc/salt/roster" not found
2022-06-02 10:05:12,434 [salt.pillar :900 ][CRITICAL][3427] Rendering SLS 'config' failed, render error:
found unexpected end of stream
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/salt/renderers/yaml.py", line 62, in render
data = yamlloader.load(yaml_data, Loader=get_yaml_loader(argline))
File "/usr/local/lib/python3.8/site-packages/salt/utils/yamlloader.py", line 169, in load
return yaml.load(stream, Loader=Loader)
File "/usr/local/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 49, in get_single_data
node = self.get_single_node()
File "yaml/_yaml.pyx", line 707, in yaml._yaml.CParser.get_single_node
File "yaml/_yaml.pyx", line 725, in yaml._yaml.CParser._compose_document
File "yaml/_yaml.pyx", line 776, in yaml._yaml.CParser._compose_node
File "yaml/_yaml.pyx", line 890, in yaml._yaml.CParser._compose_mapping_node
File "yaml/_yaml.pyx", line 776, in yaml._yaml.CParser._compose_node
File "yaml/_yaml.pyx", line 892, in yaml._yaml.CParser._compose_mapping_node
File "yaml/_yaml.pyx", line 905, in yaml._yaml.CParser._parse_next_event
yaml.scanner.ScannerError: while scanning a quoted scalar
in "<unicode string>", line 3, column 27
found unexpected end of stream
in "<unicode string>", line 4, column 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/salt/pillar/__init__.py", line 887, in render_pstate
state = compile_template(
File "/usr/local/lib/python3.8/site-packages/salt/template.py", line 99, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/usr/local/lib/python3.8/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/salt/renderers/yaml.py", line 66, in render
raise SaltRenderError(err_type, line_num, exc.problem_mark.buffer)
salt.exceptions.SaltRenderError: found unexpected end of stream
2022-06-02 10:05:12,435 [salt.pillar :1224][CRITICAL][3427] Pillar render error: Rendering SLS 'config' failed. Please see master log for details.
My sls file packages.sls
install_bash:
pkg.installed:
- pkgs:
- bash
- vim
- curl
Any idea on how to solve this situation?
Thank you
It was a problem of DNS/Cache. Issue solved after changing the hostname in minion.id ,clear cache, accepted new key and restart.

Error in Jupyter Notebook: What could be the reason?

Recently I updated R n Jupyter Lab with homebrew.
Today, I am surprised that R failed to run on ipython notebook with error below:
Error Starting Kernel
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "/opt/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/opt/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/handlers.py", line 72, in post
type=mtype))
File "/opt/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/opt/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/opt/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "/opt/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/opt/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/opt/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "/opt/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/opt/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
yielded = next(result)
File "/opt/anaconda3/lib/python3.7/site-packages/notebook/services/kernels/kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "/opt/anaconda3/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "/opt/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 259, in start_kernel
**kw)
File "/opt/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File "/opt/anaconda3/lib/python3.7/site-packages/jupyter_client/launcher.py", line 138, in launch_kernel
proc = Popen(cmd, **kwargs)
File "/opt/anaconda3/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/opt/anaconda3/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/Cellar/r/3.5.3/lib/R/bin/R': '/usr/local/Cellar/r/3.5.3/lib/R/bin/R'
Appreciate your advice.
The interesting part of the error is.
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/Cellar/r/3.5.3/lib/R/bin/R': '/usr/local/Cellar/r/3.5.3/lib/R/bin/R'
I guess you Jupyter kernel is referencing the old installation of R that you have updated.
The first thing to do is to check what is defined in your R kernel.
Check kernel
# list all kernel
jupyter kernelspec list
#Available kernels:
# ir /opt/conda/share/jupyter/kernels/ir
# ...
You should have an ir kernel.
Check the content of the kernel definition, for example:
$ cat /opt/conda/share/jupyter/kernels/ir/kernel.json
# {"argv": ["R", "--slave", "-e", "IRkernel::main()", "--args", "{connection_file}"],
# "display_name":"R",
# "language":"R"
# }
If the command in argv is incorrect you can remove an reinstall the kernel.
Remove and reinstall the kernel
See the IRkernel installation documentation for more information.
$ jupyter kernelspec remove ir
$ R
# Install IRkernel
> install.packages('IRkernel')
# Or update it if already installed
> update.packages('IRkernel')
# Install the kernel
> IRkernel::installspec()
# Or alternatively if you want to install it system-wide
> IRkernel::installspec(user = FALSE)

I open jupyter on Anaconda3 and appear kernel error, what i do?

In the kernel error appears this:
Traceback (most recent call last):
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 476, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\A0165\Anaconda3\lib\contextlib.py", line 112, in enter
return next(self.gen)
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py", line 404, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\A0165\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: No se encontrĂ³ el proceso especificado.
I recently got same error on Windows10 x86_64bit with Python3.7-32bit or Python3.8-64bit environment. In my case, the mismatch of bit and version seemed to be the root cause. At first I uninstalled all the Python versions and Anaconda, then re-installed them again as following, then the kernel error disappeared on junyper-notebook.
Windows10 x86_64bit
Python3.7.5-64bit
Anaconda3-2019.10-Windows-x86_64
*Anaconda seems to use \Python37\ path as default so my Python3.8 didn't work well. I don't know how to change the path to Python38.
Like sshinobu, I recently got this error here.
Short version - It went away after running Anaconda-Navigator, and if needed Anaconda Prompt in administrator mode. Hope that fixes it for you

Jupyter notebook fail to start kernel

I am new to Jupyter notebook when I try to create a Jupyter notebook, it fail to start the kernel by showing below error message, my python version is 3.5.2 and jupyter version is 4.2.0:
Traceback (most recent call last):
File "/home/andy/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 526, in get
value = obj._trait_values[self.name]
KeyError: 'loop'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/andy/anaconda3/lib/python3.5/site-packages/notebook/base/handlers.py", line 457, in wrapper
result = yield gen.maybe_future(method(self, *args, **kwargs))
File "/home/andy/.local/lib/python3.5/site-packages/tornado/gen.py", line 1133, in run
value = future.result()
File "/home/andy/anaconda3/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/home/andy/.local/lib/python3.5/site-packages/tornado/gen.py", line 1141, in run
yielded = self.gen.throw(*exc_info)
File "/home/andy/anaconda3/lib/python3.5/site-packages/notebook/services/sessions/handlers.py", line 62, in post
kernel_id=kernel_id))
File "/home/andy/.local/lib/python3.5/site-packages/tornado/gen.py", line 1133, in run
value = future.result()
File "/home/andy/anaconda3/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/home/andy/.local/lib/python3.5/site-packages/tornado/gen.py", line 1141, in run
yielded = self.gen.throw(*exc_info)
File "/home/andy/anaconda3/lib/python3.5/site-packages/notebook/services/sessions/sessionmanager.py", line 79, in create_session
kernel_name)
File "/home/andy/.local/lib/python3.5/site-packages/tornado/gen.py", line 1133, in run
value = future.result()
File "/home/andy/anaconda3/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/home/andy/.local/lib/python3.5/site-packages/tornado/gen.py", line 1141, in run
yielded = self.gen.throw(*exc_info)
File "/home/andy/anaconda3/lib/python3.5/site-packages/notebook/services/sessions/sessionmanager.py", line 92, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "/home/andy/.local/lib/python3.5/site-packages/tornado/gen.py", line 1133, in run
value = future.result()
File "/home/andy/anaconda3/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/home/andy/.local/lib/python3.5/site-packages/tornado/gen.py", line 326, in wrapper
yielded = next(result)
File "/home/andy/anaconda3/lib/python3.5/site-packages/notebook/services/kernels/kernelmanager.py", line 87, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "/home/andy/anaconda3/lib/python3.5/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "/home/andy/anaconda3/lib/python3.5/site-packages/jupyter_client/manager.py", line 258, in start_kernel
self.start_restarter()
File "/home/andy/anaconda3/lib/python3.5/site-packages/jupyter_client/ioloop/manager.py", line 49, in start_restarter
kernel_manager=self, loop=self.loop,
File "/home/andy/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 554, in __get__
return self.get(obj, cls)
File "/home/andy/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 533, in get
value = self._validate(obj, dynamic_default())
File "/home/andy/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 589, in _validate
value = self.validate(obj, value)
File "/home/andy/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 1681, in validate
self.error(obj, value)
File "/home/andy/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 1528, in error
raise TraitError(e)
traitlets.traitlets.TraitError: The 'loop' trait of an IOLoopKernelManager instance must be a ZMQIOLoop, but a value of class 'tornado.platform.asyncio.AsyncIOMainLoop' (i.e. <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7f1dd34e8ef0>) was specified.
And I have also checked the kernel by using below command:
jupyter kernelspec list
Get below result:
Available kernels:
python3 /home/andy/anaconda3/share/jupyter/kernels/python3
Can anyone help me?
Jupyter 4.2.0 is pretty old, and is not compatible with Tornado versions newer than 5.0. You need to either upgrade to a newer version of Jupyter or downgrade to an older version of Tornado (with pip, this would be pip install "tornado<5.0". I don't know the conda equivalent)

cling Jupyter TypeError: readlink: can't specify None for path argument

I guess I need some support on fighting with the following issue:
[I 01:32:06.539 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 81762983-2e89-47dc-a6f6-5f36d4f25865 restarted
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter-cling-kernel", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/Alexey/cling/share/cling/Jupyter/kernel/scripts/jupyter-cling-kernel", line 4, in <module>
main()
File "/Users/Alexey/cling/share/cling/Jupyter/kernel/clingkernel.py", line 317, in main
ClingKernelApp.launch_instance()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/application.py", line 595, in launch_instance
app.initialize(argv)
File "<decorator-gen-122>", line 2, in initialize
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 421, in initialize
self.init_kernel()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 360, in init_kernel
user_ns=self.user_ns,
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/configurable.py", line 405, in instance
inst = cls(*args, **kwargs)
File "/Users/Alexey/cling/share/cling/Jupyter/kernel/clingkernel.py", line 80, in __init__
whichCling = os.readlink(shutil.which('cling'))
TypeError: readlink: can't specify None for path argument
[W 01:32:09.546 NotebookApp] KernelRestarter: restart failed`
In .bash_profile:
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
export CUDA_HOME="/usr/local/cuda"
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$CUDA_HOME/lib"
export PATH="$CUDA_HOME/bin:$PATH"
export PATH="/Developer/cling/bin:$PATH"
Checked everywhere - nothing similar. Thanks in advance.
Try adding the path in .bashrc instead of .bash_profile. Or if you're using any virtual environment start the notebook in your root environment

Resources