can't import sage into python
trying to write a python/sage script and in starting i am following the example
#!/usr/bin/env sage
import sys
from sage.all import *
if len(sys.argv) != 2:
print("Usage: %s <n>" % sys.argv[0])
print("Outputs the prime factorization of n.")
sys.exit(1)
print(factor(sage_eval(sys.argv[1])))
from this sage docs link and i continue to get the variety of erros:
ModuleNotFoundError: No module named 'sage.all'; 'sage' is not a package
ImportError: No module named all
and variations thereof. sage runs from any directory just by typing sage and enter, so i dont believe its a path issue. ive also tried passing the -python argument to the shebang at the top of the script. i have tried to execute the script using:
sage -python sage.py
./sage.py
i have also tried saving the file with a .sage extension and invoking the script also as above, all of and any combinations complain of the same inability to resolve the module importing of sage into the script. i know there are a number of similar questions on this site related to that error, but they most all seemed to also have problems invoking sage successfully from the cl with just typing sage