cschwan / sage-on-gentoo

(Unofficial) Gentoo Overlay for Sage- and Sage-related ebuilds
84 stars 26 forks source link

ImportError: No module named sagenb.notebook.notebook_object #425

Closed dniku closed 5 years ago

dniku commented 8 years ago
$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.2, Release Date: 2016-05-15                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: notebook()
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-3728cb3d7c7d> in <module>()
----> 1 notebook()

/usr/lib64/python2.7/site-packages/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__call__ (/var/tmp/portage/sci-mathematics/sage-7.2/work/sage-7.2/src-python2_7/build/cythonized/sage/misc/lazy_import.c:3627)()
    384             True
    385         """
--> 386         return self._get_object()(*args, **kwds)
    387 
    388     def __repr__(self):

/usr/lib64/python2.7/site-packages/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport._get_object (/var/tmp/portage/sci-mathematics/sage-7.2/work/sage-7.2/src-python2_7/build/cythonized/sage/misc/lazy_import.c:2234)()
    244         elif self._at_startup and not startup_guard:
    245             print('Option ``at_startup=True`` for lazy import {0} not needed anymore'.format(self._name))
--> 246         self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name)
    247         alias = self._as_name or self._name
    248         if self._deprecation is not None:

ImportError: No module named sagenb.notebook.notebook_object

This is a fresh installation of Sage. I'm not sure if this is a problem with packaging or Sage itself.

kiwifb commented 8 years ago

Hum, do you have sage-notebook installed?

kiwifb commented 8 years ago

Because the sagenb (provided by the sage-notebook ebuild) is currently on it s way to deprecation to be superseded by the jupyter notebook, it is not automatically installed anymore. That and the fact that before sage 7.2 there were bits of sagenb used by sage directly and we have now fixed that.

dniku commented 8 years ago

That's right, I don't have sage-notebook. Should I install it manually, or should I install something related to jupyter instead?

kiwifb commented 8 years ago

By default sage -n should start a jupyter notebook. If you want the classic sagenb you can install it with emerge sage-notebook and you can add sagenb to sage's useflags to pull it automatically.

dniku commented 8 years ago

Thank you for your help. Unfortunately,

$ sage -n
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.2, Release Date: 2016-05-15                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
Please wait while the Sage Notebook server starts...
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/sage-notebook", line 191, in <module>
    launcher(unknown)
  File "/usr/lib/python-exec/python2.7/sage-notebook", line 60, in __init__
    from sagenb.notebook.notebook_object import notebook
ImportError: No module named sagenb.notebook.notebook_object

This is a freshly emerged Sage. (as you probably remember by this point...)

This is actually the first time I'm trying Sage, so I'd probably prefer to stick with the newer (jupyter) version.

kiwifb commented 8 years ago

I'll have to check that

sage --notebook=jupyter

should start a jupyter notebook for sure. If it doesn't I have a bug somewhere. But I'll have to check, I am sure upstream made jupyter the default for sage -n.

kiwifb commented 8 years ago

Well, I'll be. I remember discussion on sage-devel about changing the default to jupyter but -n still gets you sagenb by default so far.

dniku commented 8 years ago

Well, haha, no.

$ sage --notebook=jupyter
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.2, Release Date: 2016-05-15                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
Please wait while the Sage Notebook server starts...
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/sage-notebook", line 191, in <module>
    launcher(unknown)
  File "/usr/lib/python-exec/python2.7/sage-notebook", line 77, in __init__
    from sage.repl.ipython_kernel.kernel import have_prerequisites
  File "/usr/lib64/python2.7/site-packages/sage/repl/ipython_kernel/kernel.py", line 18, in <module>
    from ipykernel.ipkernel import IPythonKernel
  File "/usr/lib64/python2.7/site-packages/ipykernel/__init__.py", line 2, in <module>
    from .connect import *
  File "/usr/lib64/python2.7/site-packages/ipykernel/connect.py", line 13, in <module>
    from IPython.core.profiledir import ProfileDir
  File "/usr/lib64/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
    from .core.application import Application
  File "/usr/lib64/python2.7/site-packages/IPython/core/application.py", line 24, in <module>
    from IPython.core import release, crashhandler
  File "/usr/lib64/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in <module>
    from IPython.core import ultratb
  File "/usr/lib64/python2.7/site-packages/IPython/core/ultratb.py", line 121, in <module>
    from IPython.utils.terminal import get_terminal_size
  File "/usr/lib64/python2.7/site-packages/IPython/utils/terminal.py", line 27, in <module>
    import backports.shutil_get_terminal_size
ImportError: No module named shutil_get_terminal_size
kiwifb commented 8 years ago

Main tree bug, needs to go in bugzilla. ipython-4.2.0 needs to depend on backports-shutil_get_terminal_size and I need to add it and a couple of things in the keywords file.

kiwifb commented 8 years ago

This is https://bugs.gentoo.org/show_bug.cgi?id=585038

dniku commented 8 years ago

Well, after I installed backports-shutil_get_terminal_size manually it threw almost no errors.

$ sage --notebook=jupyter
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.2, Release Date: 2016-05-15                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
Please wait while the Sage Notebook server starts...
[I 02:02:46.073 NotebookApp] Writing notebook server cookie secret to /var/run/user/1000/jupyter/notebook_cookie_secret
/usr/lib64/python2.7/site-packages/widgetsnbextension/__init__.py:30: UserWarning: To use the jupyter-js-widgets nbextension, you'll need to update
    the Jupyter notebook to version 4.2 or later.
  the Jupyter notebook to version 4.2 or later.""")
[I 02:02:46.302 NotebookApp] Serving notebooks from local directory: /home/ser
[I 02:02:46.302 NotebookApp] 0 active kernels 
[I 02:02:46.302 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 02:02:46.302 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[1:1:0605/020246:ERROR:chrome_content_client.cc(309)] Failed to locate and load the component updated flash plugin.
[4852:4852:0605/020246:ERROR:chrome_content_client.cc(309)] Failed to locate and load the component updated flash plugin.
Se ha abierto una nueva ventana en la sesión actual del navegador.
[W 02:02:47.949 NotebookApp] /home/ser/.steampath doesn't exist
[W 02:02:47.956 NotebookApp] /home/ser/.steampid doesn't exist
[W 02:02:47.971 NotebookApp] /home/ser/.gtkrc-2.0-kde4 doesn't exist

(and the three last warnings repeat every minute or so)

Thank you for your help. Is there any way to make Jupyter the default notebook for -n now?

kiwifb commented 8 years ago

Those are strange but clearly out of my control. Making Jupyter the default require some patching or some editing. The file deciding that is /usr/lib/python-exec/python2.7/sage-notebook at line 169 and after you have

notebook_launcher = {
    'default': NotebookSageNB,   # change this to change the default
    'sagenb': NotebookSageNB,
    'ipython': NotebookJupyter,
    'jupyter': NotebookJupyter,
} 

I think it is clear wht you would need to do. Alternatively you could create yourself an alias or a desktop shortcut with all the right stuff you want.

dniku commented 8 years ago

Thank you for helping me setting up it. I really appreciate it.

dniku commented 8 years ago

(the issue should probably be kept open since it's currently unresolved for other new users)

kiwifb commented 5 years ago

OK, the default now is to open the legacy notebook exporter which offers you a choice between legacy and jupyter or converting old notebook to jupyter.

Do you think it is good enough for closing this ticket?

kiwifb commented 5 years ago

No answer, closing.