jupyter nbconvert broken

901 views
Skip to first unread message

Pstrang Rzekle

unread,
Sep 4, 2017, 1:40:11 PM9/4/17
to sage-support
I'm unable to use nbconvert from the command line or from within the jupyter notebook.

===============================================================================
[user@host ~]$ jupyter nbconvert --to latex test1.ipynb --log-level=DEBUG

Traceback (most recent call last):
  File "/usr/bin/jupyter-nbconvert", line 11, in <module>
    load_entry_point('nbconvert', 'console_scripts', 'jupyter-nbconvert')()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 570, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2687, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2341, in load
    return self.resolve()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2347, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/mitchw/Downloads/nbconvert/nbconvert/__init__.py", line 4, in <module>
    from .exporters import *
  File "/home/mitchw/Downloads/nbconvert/nbconvert/exporters/__init__.py", line 1, in <module>
    from .base import (export, get_exporter, 
  File "/home/mitchw/Downloads/nbconvert/nbconvert/exporters/base.py", line 10, in <module>
    from traitlets.log import get_logger
ImportError: No module named traitlets.log


[user@host ~]$ sudo pip install --upgrade traitlets
[sudo] password for user: 
Requirement already up-to-date: traitlets in /usr/lib/python2.7/site-packages
Requirement already up-to-date: six in /usr/lib/python2.7/site-packages (from traitlets)
Requirement already up-to-date: enum34; python_version == "2.7" in /usr/lib/python2.7/site-packages (from traitlets)
Requirement already up-to-date: ipython-genutils in /usr/lib/python2.7/site-packages (from traitlets)
Requirement already up-to-date: decorator in /usr/lib/python2.7/site-packages (from traitlets)

================================================================================

Thank you for any suggestions!

Vincent Delecroix

unread,
Sep 7, 2017, 6:04:12 PM9/7/17
to sage-s...@googlegroups.com
On 04/09/2017 12:40, Pstrang Rzekle wrote:
> File "/home/mitchw/Downloads/nbconvert/nbconvert/__init__.py", line 4, in

How did you instal Jupyter? Why is it in /home/mitchw/Downloads?

Pstrang Rzekle

unread,
Sep 9, 2017, 6:48:11 PM9/9/17
to sage-support
After trying numerous things and not having any luck with the "sage-8.0-Fedora_25-x86_64.tar", I tried nbconvert from github: https://github.com/jupyter/nbconvert.
Still didn't work, so I have since uninstalled it (sudo pip uninstall nbconvert), and reinstalled the pip version (sudo pip install nbconvert).

No difference in results, same error from the command line. :(

Dima Pasechnik

unread,
Sep 10, 2017, 4:54:40 AM9/10/17
to sage-support


On Saturday, September 9, 2017 at 11:48:11 PM UTC+1, Pstrang Rzekle wrote:
After trying numerous things and not having any luck with the "sage-8.0-Fedora_25-x86_64.tar", I tried nbconvert from github: https://github.com/jupyter/nbconvert.
Still didn't work, so I have since uninstalled it (sudo pip uninstall nbconvert), and reinstalled the pip version (sudo pip install nbconvert).

No difference in results, same error from the command line. :(

Can you try starting nbconvert from Sage rather than from the system's jupyter?
That is, starting sage with -n command line option will bring up nbconvert.

$ sage -n

[...]
Please wait while the SageNB export server starts...
[W 09:51:00.373 NotebookApp] server_extensions is deprecated, use nbserver_extensions
[I 09:51:00.375 NotebookApp] Using MathJax: nbextensions/mathjax/MathJax.js
[I 09:51:00.688 NotebookApp] Serving notebooks from local directory: /home/dima/Sage/sage-dev/src/sage
[I 09:51:00.688 NotebookApp] 0 active kernels 
[I 09:51:00.688 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=[...]
[I 09:51:00.688 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:51:00.690 NotebookApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
-----------------
and I get a browser tab with the needed menu etc...

Pstrang Rzekle

unread,
Sep 10, 2017, 1:27:57 PM9/10/17
to sage-support
[user@host ~]$ sage -n jupyter
The above starts a jupyter notebook correctly.  After installing some additional packages, I can now "Download as.../PDF via LaTeX (.pdf)" correctly.  Yea!

However, after using "%display latex" in the notebook, the equations are still rendered as text in the PDF, not LaTeX as they are displayed in the notebook.

This is the reason for trying to use the command-line to generate the LaTeX so I can use other tools to generate actual LaTeX equations from the notebook.

===========================================================
[user@host ~]$ jupyter nbconvert --to latex test1.ipynb 
Traceback (most recent call last):
  File "/usr/bin/jupyter-nbconvert", line 7, in <module>
    from nbconvert.nbconvertapp import main
  File "/usr/lib/python2.7/site-packages/nbconvert/__init__.py", line 4, in <module>
    from .exporters import *
  File "/usr/lib/python2.7/site-packages/nbconvert/exporters/__init__.py", line 1, in <module>
    from .base import (export, get_exporter, 
  File "/usr/lib/python2.7/site-packages/nbconvert/exporters/base.py", line 10, in <module>
    from traitlets.log import get_logger
ImportError: No module named traitlets.log
===========================================================

Thank you!

Pstrang Rzekle

unread,
Sep 11, 2017, 1:52:36 PM9/11/17
to sage-support
Also, just noticed that the jupyter notebook apparently isn't flushing old versions of the notebook before converting to PDF via LaTeX.  A major change and re-saving of the notebook still generates the old PDF.  Exiting and restarting the jupyter server still keeps the old notebook version to generate the PDF.  The only fix I found required me to give the notebook a new name to generate an updated PDF.  :(
Reply all
Reply to author
Forward
0 new messages