Ask Your Question

PackageNotFoundError and SyntaxError

asked 2017-12-31 07:05:46 +0100

louisng114 gravatar image

updated 2018-01-02 04:08:17 +0100

In a notebook, when I entered

p = Polyhedron(ieqs=[(0,1,0,0,0,0,0,0,0),(0,0,0,0,0,1,0,0,0),(0,-1,1,0,0,0,0,0,0),(0,0,-1,1,0,0,0,0,0),(0,0,0,-1,1,0,0,0,0),(0,0,0,0,-1,0,0,0,1),(0,0,0,0,0,-1,1,0,0),(0,0,0,0,0,0,-1,1,0),(0,0,0,0,0,0,0,-1,1),(1,-1,-1,-1,-1,-1,-1,-1,-1)])


H1 = Polyhedron(eqns=[(0,-1,0,0,0,1,0,0,0)])
q1 = p.intersection(H1)

everything was fine, but when I typed in


I got the following message:

 --------------------------------------------------------------------------- PackageNotFoundError                  
 Traceback (most recent call last)
 <ipython-input-75-395b663ed32e> in
 ----> 1 (Integer(1000)*q1).integral_points_count()

 in integral_points_count(self,
 verbose, use_Hrepresentation,
 preprocess, **kwds)
     216                 cdd=True,
     217                 verbose=verbose,
 --> 218                 **kwds)

 in count(arg, ehrhart_polynomial,
 raw_output, verbose, **kwds)
     148     except OSError:
     149         from sage.misc.package import PackageNotFoundError
 --> 150         raise PackageNotFoundError('latte_int')
     152     ans, err = latte_proc.communicate(arg)

 PackageNotFoundError: the package
 'latte_int' was not found. You can
 install it by running 'sage -i
 latte_int' in a shell

However, when I used sage -i latte_int, I got the error message

  File "<ipython-input-76-d56a71c64d98>", line 1
    sage -i latte_int
SyntaxError: invalid syntax

Does anyone know why am I getting these conflicting messages? I tried it both on a VirtualBox and Windows, but they both give the same messages.

EDIT2: sage -i latte_int works in VirtualBox when typed in a terminal.

EDIT: When I open a shell, there is a message on top saying

Starting subshell with Sage environment variable set. Don't forget to exit when you are done. Beware: * Do not do anything with other copies of Sage on your system. * Do not use this for installing Sage packages using "sage -i" or for running "make" at Sage's root directory. These should be done outside the Sage shell.

When I enter sage -i latte_int in anyway, I get

make: *** No rule to make target 'all-toolchain'.  Stop.

Typing sage -i latte_int in a terminal or console gives the same result.

Entering !sage -i latte_int in a Notebook, I get an OSError

OSError                                   Traceback (most recent call last)
<ipython-input-1-f5647ef902a7> in <module>()
----> 1 get_ipython().system(u'sage -i latte_int')

/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/ in system_piped(self, cmd)
   2207         # a non-None value would trigger :func:`sys.displayhook` calls.
   2208         # Instead, we store the exit_code in user_ns.
-> 2209         self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1))
   2211     def system_raw(self, cmd):

/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/utils/ in system(self, cmd)
    155                 child = pexpect.spawnb(, args=['-c', cmd]) # Pexpect-U
    156             else:
--> 157                 child = pexpect.spawn(, args=['-c', cmd])  # Vanilla Pexpect
    158             flush = sys.stdout.flush
    159             while True:

/opt/sagemath-8.1/local/lib/python2.7/site-packages/pexpect/ in __init__(self, command, args, timeout, maxread, searchwindowsize, logfile, cwd, env, ignore_sighup, echo, preexec_fn, encoding, codec_errors, dimensions)
    196    = '<pexpect factory incomplete>'
    197         else:
--> 198             self._spawn(command, args, preexec_fn, dimensions)
    200     def __str__(self):

/opt/sagemath-8.1/local/lib/python2.7/site-packages/pexpect/ in _spawn(self, command, args, preexec_fn, dimensions)
    297         self.ptyproc = self._spawnpty(self.args, env=self.env,
--> 298                                      cwd=self.cwd, **kwargs)
    300 =

/opt/sagemath-8.1/local/lib/python2.7/site-packages/pexpect/ in _spawnpty(self, args, **kwargs)
    307     def _spawnpty(self, args, **kwargs):
    308         '''Spawn a pty and return an instance of PtyProcess.'''
--> 309         return ptyprocess.PtyProcess.spawn(args, **kwargs)
    311     def close(self, force=True):

/opt/sagemath-8.1/local/lib/python2.7/site-packages/ptyprocess/ in spawn(cls, argv, cwd, env, echo, preexec_fn, dimensions)
    219         if use_native_pty_fork:
--> 220             pid, fd = pty.fork()
    221         else:
    222             # Use internal fork_pty, for Solaris

/opt/sagemath-8.1/local/lib/python2.7/ in fork()
    107     master_fd, slave_fd = openpty()
--> 108     pid = os.fork()
    109     if pid == CHILD:
    110         # Establish a new session.

OSError: [Errno 11] Resource temporarily unavailable
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-01-01 20:18:16 +0100

slelievre gravatar image

To expand on @vdelecroix's answer, you could try the following (let us know which of them work!).

  • using Sage-Windows: open a Sage shell and type sage - i latte_int there;
  • using the SageAppliance in VirtualBox: open a terminal and type sage -i latte_int there.

If you don't know how to open a Sage shell or a terminal, there is a workaround, using !. Inside a running Sage, if you type something like !<command>, then Sage will tell the shell to execute the command <command>.

So, inside Sage, you could type the following (don't forget the initial !):

`!sage -i latte_int``

and that should launch the installation of latte_int. It might be that you then need to restart Sage to use it.

I think that should definitely work in the SageAppliance. Not sure about the Sage-Windows installation. Let us know!

edit flag offensive delete link more


It still doesn't work. I updated the question to show the new errors I am getting.

louisng114 gravatar imagelouisng114 ( 2018-01-01 22:37:05 +0100 )edit

It works in VM, but not Windows.

louisng114 gravatar imagelouisng114 ( 2018-01-02 04:08:54 +0100 )edit

Installing extra packages with Sage-Windows works for some packages, but not all.

It is a known limitation. I think it depends whether installing them requires re-building Sage.

Thanks for confirming this works in the SageAppliance virtual machine for VirtualBox.

slelievre gravatar imageslelievre ( 2018-01-02 05:41:33 +0100 )edit

Sage for Windows doesn't currently support installing optional packages, but this a useful data point. I'm thinking that for the next release some optional packages will come pre-installed, but it's hard to know which ones to include. Obviously, seeing explicitly that someone was trying to use a specific package is evidence that it should be included.

Iguananaut gravatar imageIguananaut ( 2018-01-05 14:09:30 +0100 )edit

Thanks @Iguananaut for that!

For reference, which optional packages to include in Sage for Windows is discussed at

slelievre gravatar imageslelievre ( 2018-01-06 01:03:03 +0100 )edit

answered 2018-01-01 11:54:46 +0100

vdelecroix gravatar image

The problem is that the command sage -i latte_int has to be typed on your system console, not on the Sage prompt. Sage packages can not be installed from within Sage.

To install a package, I believe that you need a Sage version compiled from source.

edit flag offensive delete link more


How do I do that?

louisng114 gravatar imagelouisng114 ( 2018-01-01 18:51:54 +0100 )edit

Did you try the installation command on your prompt (you have to open a console)? To compile from sources, instructions are here.

vdelecroix gravatar imagevdelecroix ( 2018-01-01 19:24:41 +0100 )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



Asked: 2017-12-31 07:05:46 +0100

Seen: 575 times

Last updated: Jan 02 '18