Ask Your Question

Running a prewritten program

asked 2020-05-02 19:55:45 +0200

Schrift gravatar image

In Python you have IDLE, which allows you to write a program and then run it. I am looking for something similar for sage, so that you don't have to type it line for line in sagemath. Is there something that looks like IDLE for sage?

I had a look at this the programmig page of the docs (I cannot post the link due to 'karma' whatever that is), and tried to do it by creating a program in a .txt file and then renaming it to .sage, but sage said that it could not find the file. The error says OSError: did not find file 'C:\Users\Martin\Desktop\example.sage' to load or attach

and the exact thing I wrote is


I double checked the path and file name, I am pretty sure that there are no mistakes in that.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-05-03 10:09:58 +0200

Sébastien gravatar image

updated 2020-05-03 22:03:11 +0200

See also this other question: I think you need to write it this way:

sage: load("/Users/Martin/Desktop/example.sage")

or with a relative path:

sage: load("./Desktop/example.sage")
sage: %load ./Desktop/example.sage                           # alternative syntax
sage: %runfile ./Desktop/example.sage                        # alternative syntax

You may also like

sage: attach("./Desktop/example.sage")
sage: %attach ./Desktop/example.sage                         # alternative syntax

which reloads the file automatically on save.

edit flag offensive delete link more


The suggestion load("./Desktop/example.sage") worked, thank you!

Schrift gravatar imageSchrift ( 2020-05-03 15:54:06 +0200 )edit

I changed @Sébastien's comment to an answer, so that @Schrift can accept it as solving the question.

slelievre gravatar imageslelievre ( 2020-05-03 21:25:01 +0200 )edit

I wasn't sure since I don't have Windows. But since it seems to work, you are right. Thank you Samuel.

Sébastien gravatar imageSébastien ( 2020-05-03 22:04:13 +0200 )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-05-02 19:55:45 +0200

Seen: 214 times

Last updated: May 03 '20