Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using SageMath in Python 2.7

I am trying to use IDLE with Python 2.7.15 and use functions from Sage 8.2 on a Windows 10 machine. I know that I have to have Python 2.x (which I do). My script is the following:

#! C:\Program Files\SageMath 8.2\runtime\bin\env sage -python

from sage.all import *

Suits = Set(["Hearts", "Diamonds", "Spades", "Clubs"])
Values = Set([2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King", "Ace"])
Cards = cartesian_product([Values, Suits])

print(Cards.cardinality)

(from the combinat package/documentation and question/8215/using-sage-in-a-python-cgi-script/ which I can't post a direct link to because this is my first question). Then when I try to run it in IDLE I get

Traceback (most recent call last):
File "C:/Users/ME/Documents/Math/Programming/Playing/playing_1.py", line 3, in <module>
from sage.all import *
ImportError: No module named sage.all

For what its worth, I get the same error when trying to import numpy, sklearn, and pandas. I have Anaconda downloaded but I am using Python 3 in that so I presume that is where that issue is coming from. If I am wrong I'd love to know!

Using SageMath in Python 2.7IDLE

I am trying to use IDLE with Python 2.7.15 and use functions from Sage 8.2 on a Windows 10 machine. I know that I have to have Python 2.x (which I do). My script is the following:

#! C:\Program Files\SageMath 8.2\runtime\bin\env sage -python

from sage.all import *

Suits = Set(["Hearts", "Diamonds", "Spades", "Clubs"])
Values = Set([2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King", "Ace"])
Cards = cartesian_product([Values, Suits])

print(Cards.cardinality)

(from the combinat package/documentation and question/8215/using-sage-in-a-python-cgi-script/ which I can't post a direct link to because this is my first question). Then when I try to run it in IDLE I get

Traceback (most recent call last):
File "C:/Users/ME/Documents/Math/Programming/Playing/playing_1.py", line 3, in <module>
from sage.all import *
ImportError: No module named sage.all

For what its worth, I get the same error when trying to import numpy, sklearn, and pandas. I have Anaconda downloaded but I am using Python 3 in that so I presume that is where that issue is coming from. If I am wrong I'd love to know!

EDIT: I realize I did not ask a question. My question is, can anyone help me get this to work? Thank you!