ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 08 Jun 2013 17:45:16 +0200Pb with SageTeXhttps://ask.sagemath.org/question/9836/pb-with-sagetex/ 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]Sat, 23 Feb 2013 09:19:23 +0100https://ask.sagemath.org/question/9836/pb-with-sagetex/Answer by PhGriffiths for <p>Hi</p>
<p>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?</p>
<p>Thanks u for your answer.</p>
<p>(PS: I'm beginner... and french!)</p>
<pre><code>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]
</code></pre>
https://ask.sagemath.org/question/9836/pb-with-sagetex/?answer=14586#post-id-14586Well, 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...Sat, 23 Feb 2013 18:13:40 +0100https://ask.sagemath.org/question/9836/pb-with-sagetex/?answer=14586#post-id-14586Answer by David Bailey for <p>Hi</p>
<p>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?</p>
<p>Thanks u for your answer.</p>
<p>(PS: I'm beginner... and french!)</p>
<pre><code>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]
</code></pre>
https://ask.sagemath.org/question/9836/pb-with-sagetex/?answer=14917#post-id-14917I 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'
Mon, 13 May 2013 02:16:21 +0200https://ask.sagemath.org/question/9836/pb-with-sagetex/?answer=14917#post-id-14917Comment by Rob E. for <p>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</p>
<p>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.</p>
<p>Near the end of sagetex.py are three lines separated by other code:</p>
<pre><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')
</code></pre>
<p>Replace each of these lines by the corresponding line below:</p>
<pre><code> 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')
</code></pre>
<p>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.</p>
<p>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</p>
<pre><code> self.plotdir = 'sage-plots-for-' + jobname + '.tex'
</code></pre>
<p>with</p>
<pre><code> localdir = "/".join((traceback.extract_stack(limit=2)[0][0][0:-11]).split("/")[:-1])
self.plotdir = localdir+'/sage-plots-for-' + jobname + '.tex'
</code></pre>
https://ask.sagemath.org/question/9836/pb-with-sagetex/?comment=17539#post-id-17539This worked for me but I had to hardcode a specific directory in place of the traceback item.Sat, 08 Jun 2013 17:45:16 +0200https://ask.sagemath.org/question/9836/pb-with-sagetex/?comment=17539#post-id-17539