Cannot import name "Category"
Hello! (Tried to post this, told I didn't have enough karma for links, but it's the virasoro algebra from the sagemath documentation, and then the github link for that same site.)
BACKGROUND: I'm attempting to use [the virasoro algebra sagemath stuff]. I literally clicked source (brought me to [the virasoro algebra github page thing] ), and then copy/pasted the source code into a .py file in VS Code running in/on/around WSL:Ubuntu (so that I can use the sage interpreter).
When I import that source file (call it source.py
) into another file (call it main.py
) and trying to run main.py
, I receive an error (see the traceback below). The error is from ~/sage/structure/...
files, though, not source.py
.
QUESTION: How do I successfully import name Category
? Is this a common issue? Do I need to import something else first?
Further Notes/Attempted Solutions, Troubleshooting:
The import still fails in the same spot, even if I add from sage.all import *
to the preamble.
I installed sage via/with the wsl --install
route. I used miniforge3
if that matters. I am not yet technically adept (I am coding-stupid).
There are no other files named sage
that could be shadowing the right one.
Compiled extension files (.so / .pyd) do exist for Sage internals. (I used ai for help troubleshooting and it suggested this. I am not entirely sure what it means...)
There are no circular imports; source.py
is the only file I'm importing into main.py
.
(edited line here ->): I get the error if I run the file in the WSL terminal, too.
Let me know if any other information is needed, and thank you!
Error message: conda run --live-stream --name sage python /home/babushkat/mrns_project/mrns
Traceback (most recent call last):
File "/home/babushkat/mrns_project/mrns", line 1, in <module>
from Witt_algebra import *
File "/home/babushkat/mrns_project/Witt_algebra.py", line 19, in <module>
from sage.categories.lie_algebras import LieAlgebras
File "/home/babushkat/miniforge3/envs/sage/lib/python3.11/site-packages/sage/categories/lie_algebras.py", line 24, in <module>
from sage.categories.category import JoinCategory, Category
File "/home/babushkat/miniforge3/envs/sage/lib/python3.11/site-packages/sage/categories/category.py", line 109, in <module>
from sage.misc.c3_controlled import _cmp_key, _cmp_key_named, C3_sorted_merge
File "sage/misc/c3_controlled.pyx", line 369, in init sage.misc.c3_controlled (build/cythonized/sage/misc/c3_controlled.c:15760)
File "/home/babushkat/miniforge3/envs/sage/lib/python3.11/site-packages/sage/structure/__init__.py", line 3, in <module>
import sage.structure.element
File "sage/structure/element.pyx", line 1, in init sage.structure.element (build/cythonized/sage/structure/element.c:47835)
File "sage/structure/category_object.pyx", line 62, in init sage.structure.category_object (build/cythonized/sage/structure/category_object.c:13626)
ImportError: cannot import name Category
ERROR conda.cli.main_run:execute(127): conda run python /home/babushkat/mrns_project/mrns failed. (See above for error)