Ask Your Question
1

How do you load a file to the SageMath 9.1 Console?

asked 2020-11-28 05:57:44 +0200

updated 2020-11-28 21:41:04 +0200

FrédéricC gravatar image

I am trying to follow the Loading and Attaching Sage files tutorial. I am working on Windows 10. I created an example.sage file by simply writing a .txt file and changing the extension to .sage, and put it on my desktop, located at

C:/Users/vika/Desktop/example.sage.

In the SageMath 9.1 Console, I get the following issues depending on the type of slash

sage: load("C:/Users/vika/Desktop/example.sage")
OSError: did not find file 'C:/Users/vika/Desktop/example.sage' to load or attach
sage: load("C:\Users\vika\Desktop\example.sage")
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Where am I supposed to put this file in order to load it? I know that sage is installed at C:/Users/vika/AppData/Local/SageMath 9.1 if that matters.

edit retag flag offensive close merge delete

Comments

try load(r"C:\Users\vika\Desktop\example.sage") ?

FrédéricC gravatar imageFrédéricC ( 2020-11-28 20:11:55 +0200 )edit
FrédéricC gravatar imageFrédéricC ( 2020-11-28 21:42:57 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-12-21 05:40:49 +0200

Here's how I figured it out on Windows 10 with SageMath 9.1, for any future persons confused by this.

  1. I decided to put my Sage scripts in the folder C:\scripts\sage.

  2. I added this path to Sage's load attach path so Sage knows where to look. I did this in the console with

    sage: load_attach_path('C:\\scripts\\sage')

  3. To load eaxmple.sage from the above directory, I can now simply use

    sage: load('example.sage')

edit flag offensive delete link more

Comments

Well done! You should accept your own answer to mark the question as solved.

slelievre gravatar imageslelievre ( 2020-12-21 06:30:36 +0200 )edit

@slelievre Thank you, I still need 50 rep points to do so.

vikahdv@gmail.com gravatar imagevikahdv@gmail.com ( 2020-12-22 05:55:55 +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

Stats

Asked: 2020-11-28 05:57:44 +0200

Seen: 251 times

Last updated: Dec 21 '20