Ask Your Question
0

Pb with SageTeX

asked 2013-02-23 02:19:23 -0500

PhGriffiths gravatar image

updated 2015-01-14 13:14:04 -0500

FrédéricC gravatar image

Hi

When I run Sage after TexShop on the file .sage created by TeX, I think that sagetex.sty works well, but, at the end of the process, I've got this error message below and it stops. What's wrong?

Thanks u for your answer.

(PS: I'm beginner... and french!)

Last login: Sat Feb 23 15:04:21 on ttys002
/Applications/Sage-5.6-OSX-64bit-10.6.app/Contents/Resources/sage/sage /Users/janyphiphi/Desktop/example.sagetex.sage; exit
marx:~ janyphiphi$ /Applications/Sage-5.6-OSX-64bit-10.6.app/Contents/Resources/sage/sage /Users/janyphiphi/Desktop/example.sagetex.sage; exit
Processing Sage code for example.tex...
Inline formula 0
Inline formula 1
Inline formula 2
Inline formula 3
Code block begin...end
Inline formula 4
Inline formula 5
Inline formula 6
Code block begin...end
Inline formula 7
Inline formula 8
Code block begin...end
Traceback (most recent call last):
  File "/Users/janyphiphi/Desktop/example.sagetex.py", line 69, in <module>
    _st_.endofdoc()
  File "/Applications/Sage-5.6-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py", line 282, in endofdoc
    sagef = open(self.filename + '.sagetex.sage', 'r')
IOError: [Errno 2] No such file or directory: 'example.sagetex.sage'
logout

[Opération terminée]
edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2013-05-12 19:16:21 -0500

David Bailey gravatar image

updated 2013-05-14 08:35:38 -0500

I ran into the same problem with Sage Version 5.9-OSX-64bit-10.8. Previous versions from a couple of years ago worked fine. Sagetex seems to lose track of the directory of the LaTeX file, so the two files mentioned above are placed in the user's home directory instead of the directory where the LaTeX file is located. If

There must be a better solution, but here is a hack that works by replacing three lines in sagetex.py, found in /Applications/Sage-5.9-OSX-64bit-10.8.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py on my Mac.

Near the end of sagetex.py are three lines separated by other code:

   sagef = open(self.filename + '.sagetex.sage', 'r')
   ...
   os.rename(self.filename + '.sagetex.sout.tmp', self.filename + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', self.filename + '.sagetex.scmd')

Replace each of these lines by the corresponding line below:

   sagef = open(traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sage', 'r')
   …
   os.rename(self.filename + '.sagetex.sout.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.sout')
   …
   os.rename(self.filename + '.sagetex.scmd.tmp', traceback.extract_stack(limit=2)[0][0][0:-11] + '.sagetex.scmd')

I use the Python traceback module to identify the full path+filename of the script that calls sagetex.py, and then I strip the extension (".sagetex.sage") from this to provide the base to construct the necessary correct full filenames. This is neither elegant nor necessarily robust, but it solves the problem for me for now. You made need to modify the solution depending on the file structure and notation of your system.

Note that the 'sage-plots-for-…' plot folder is also put in the main user directory. In order to get the plot folder into the current local directory, look in sagetex.py and replace the line

    self.plotdir = 'sage-plots-for-' + jobname + '.tex'

with

    localdir = "/".join((traceback.extract_stack(limit=2)[0][0][0:-11]).split("/")[:-1])
    self.plotdir = localdir+'/sage-plots-for-' + jobname + '.tex'
edit flag offensive delete link more

Comments

This worked for me but I had to hardcode a specific directory in place of the traceback item.

Rob E. gravatar imageRob E. ( 2013-06-08 10:45:16 -0500 )edit
0

answered 2013-02-23 11:13:40 -0500

PhGriffiths gravatar image

updated 2013-02-24 00:09:55 -0500

Well, I've found that sagetex creates files .stout.temp and .scmd.temp in the main user folder. And when I drag these files in the wright place (removing the .temp extension), TeXShop works and compile successfully! Good!

And also when I work directly in \users\

But how can sage put directly the files in the right folder? Question is still open...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-02-23 02:19:23 -0500

Seen: 795 times

Last updated: May 14 '13