Ask Your Question

Cython: undeclared name not builtin

asked 2020-01-03 10:32:28 -0600

Bob67846 gravatar image

Loading a .spyx file with

 def bla(W):


undeclared name not builtin: RootSystem

Is there a library that I need to include?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2020-01-03 13:11:49 -0600

nbruin gravatar image

updated 2020-01-04 16:28:30 -0600

It looks like you should:

sage: import_statements(RootSystem)
from sage.combinat.root_system.root_system import RootSystem

As you can see in the documentation of import_statements, it tries to find out from where the symbol requested should be imported and returns a string that describes a command to do that import. So, in your case, it suggests to use

from sage.combinat.root_system.root_system import RootSystem
edit flag offensive delete link more


Thanks, this was helpful - the right answer is

from sage.all import RootSystem
Bob67846 gravatar imageBob67846 ( 2020-01-03 14:11:55 -0600 )edit

If you check the contents of sage.all, you'll see that it consists entirely of imports from other modules. There is something to say for importing symbols from their original location, which is why import_statements traces the import to its actual origin. I wouldn't say the import from sage.all is wrong but it's definitely not the right answer.

nbruin gravatar imagenbruin ( 2020-01-03 21:42:34 -0600 )edit

Sorry I'm new to this, but import_statements(RootSystem) didn't seem to work for Cython - I suppose the "right" answer might then be

from sage.combinat.root_system.root_system import RootSystem
Bob67846 gravatar imageBob67846 ( 2020-01-04 15:15:51 -0600 )edit

... and that's exactly what you meant. Woops!

Bob67846 gravatar imageBob67846 ( 2020-01-04 19:20:41 -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-01-03 10:32:28 -0600

Seen: 520 times

Last updated: Jan 04