Ask Your Question

Get the error "NameError: name '_interact_' is not defined" when run sagenb.

asked 2020-09-18 22:44:33 -0600

Xie gravatar image

updated 2020-09-19 00:05:44 -0600

Hi, I still want to run sagenb for sagemath 9.1. I follow use the following codes to compile sage 9.1.

make configure;   ./configure --with-python=2; make build

Then I run ‘ ./sage -i sagenb’. But I get errors in the notebook:

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "", line 8, in <module>


NameError: name '_interact_' is not defined

This problem may be caused by the codes in sage/local/lib/python2.7/site-packages/sagenb-1.1.3-py2.7.egg/sagenb/notebook/

   def initialize_sage(self):
            S = self.__sage
                from . import misc
                cmd = '''import base64
import as _support_
import sagenb.notebook.interact as _interact_ # for setting current cell id
....  '''


I think 'cmd' is not be executed. If I put some error code in 'cmd', there were nothing happened.

edit retag flag offensive close merge delete


One way to get SageNB to build is to use --enable-sagenb=yes at the ./configure step.

In the situation where Sage is already built,

  • either run the configure step again with --enable-sagenb and run make again
  • or, without re-running the configure, step, build SageNb with make sagenb

Then run sage -n sagenb to launch the SageNB notebook server.

slelievre gravatar imageslelievre ( 2020-09-20 04:12:31 -0600 )edit

1 answer

Sort by » oldest newest most voted

answered 2020-09-20 03:35:25 -0600

slelievre gravatar image

updated 2020-09-20 04:08:43 -0600

Building Sage 9.1 and SageNB from source

Here are the steps to build Sage and SageNB from source, and to launch the SageNB notebook.

Build Sage and SageNB

Here are the steps I would suggest.

Note that the ./configure output might end with a list of recommendations of additional system packages to install. Following those recommendations can speed up the make step.

If you know you already have all the possible recommended software and you want the ./configure step to be less verbose, add -q (for "quiet") to the ./configure line, after --enable-sagenb=yes.



$ V=0
$ MAKE='make -j1'
$ make configure
$ ./configure --with-python=2 --enable-sagenb=yes


$ make -s V=0


Preliminary brew installation

If brew is not installed yet, install it following the instructions at

Then run

$ brew update
$ brew install autoconf automake bdw-gc boost cairo ccache \
  cmake coreutils cryptominisat curl curl-openssl docutils \
  ffmpeg fontconfig freetype gambit gcc@9 gd gettext glib \
  glpk gmp gnutls gsl imagemagick isl jpeg libffi libmpc \
  libogg libomp libpng libtiff libtool mpfi mpfr mpir nauty \
  ncurses ninja numpy octave open-mpi openblas openjdk \
  openjpeg openssl@1.1 pandoc pari pkg-config ppl python@3.7 \
  r readline scipy scons sip sphinx-doc sqlite suite-sparse \
  wget xz yasm zeromq


$ V=0
$ MAKE='make -j1'
$ source .homebrew-build-env
$ make configure
$ FC=gfortran-9 ./configure --with-python=2 --enable-sagenb=yes


$ make -s V=0 openssl
$ make -s V=0

Symbolic link

Add a symbolic link to your Sage installation somewhere in your PATH.

For example by running this from the sage root folder:

$ ln -sf `pwd`/sage /usr/local/bin

of if that complains about a permission problem,

$ sudo ln -sf `pwd`/sage /usr/local/bin

which might require entering the password for your user account on the computer on which you are installing.

Check that this worked by running

$ which sage
$ sage --version

Launch the SageNB notebook

Launch the Sage notebook by running this in the terminal:

$ sage -n sagenb
edit flag offensive delete link more


Unfortunately, I did this and still the same error。 have you tried?

Xie gravatar imageXie ( 2020-09-24 23:05:27 -0600 )edit

This computer no longer had a Python2-based Sage.

I installed it again when writing my answer, and tested it.

slelievre gravatar imageslelievre ( 2020-09-25 06:37:56 -0600 )edit

Do you get errors at the time of starting the sagenb notebook?

Or does it start without error, and do you get an error when executing some code?

slelievre gravatar imageslelievre ( 2020-09-25 06:38:56 -0600 )edit

When I starting the sagenb notebook,there are some errors as follows: Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")] handshake failed; returned -1, SSL error code 1, net_error -202

In the notebook, the error just as my question. That is "NameError: name '_interact_' is not defined. "

Xie gravatar imageXie ( 2020-09-29 06:08:57 -0600 )edit

I have try Arch linux and Ubuntu 18.04. All have the problem "NameError: name '_interact_' is not defined. " .

Xie gravatar imageXie ( 2020-09-29 06:17:02 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-09-18 22:44:33 -0600

Seen: 112 times

Last updated: Sep 20 '20