ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 Nov 2020 12:24:27 -0600file with extension swshttps://ask.sagemath.org/question/40136/file-with-extension-sws/ Hi All,
I downloaded several SageMath files with extension sws, but I am unable to open them with SageMath 8.0 on Windows native. Is there any translator from sws to ipynb file? How should I proceed?
Thanks,
Daniel
Wed, 13 Dec 2017 08:06:09 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/Comment by Iguananaut for <p>Hi All,</p>
<p>I downloaded several SageMath files with extension sws, but I am unable to open them with SageMath 8.0 on Windows native. Is there any translator from sws to ipynb file? How should I proceed?</p>
<p>Thanks,</p>
<p>Daniel</p>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=40155#post-id-40155This is a possible duplicate of https://ask.sagemath.org/question/35873/how-to-automatically-convert-many-sws-to-ipynb/Thu, 14 Dec 2017 05:53:58 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=40155#post-id-40155Answer by Sébastien for <p>Hi All,</p>
<p>I downloaded several SageMath files with extension sws, but I am unable to open them with SageMath 8.0 on Windows native. Is there any translator from sws to ipynb file? How should I proceed?</p>
<p>Thanks,</p>
<p>Daniel</p>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?answer=54174#post-id-54174Since sagemath-9.2 (see ticket [#28838](https://trac.sagemath.org/ticket/28838)), the command `sage -sws2rst` was resurrected via a new pip-installable package sage-sws2rst. It can be installed in Sage 9.2 using `sage -i sage_sws2rst`.
Below is an example of usage. First we download a sage worksheet (.sws) prepared for Sage Days 20 at CIRM (Marseille, 2010):
$ wget http://slabbe.org/Sage/2010-perpignan/CIRM_Tutorial_1.sws
$ ls
CIRM_Tutorial_1.sws
We translate the sws worksheet into a ReStructuredText syntax file (.rst) using sage -sws2rst. This creates also a directory of images:
$ sage -sws2rst CIRM_Tutorial_1.sws
Processing CIRM_Tutorial_1.sws
File at CIRM_Tutorial_1.rst
Image directory at CIRM_Tutorial_1_media
$ ls
CIRM_Tutorial_1_media CIRM_Tutorial_1.rst CIRM_Tutorial_1.sws
Then, we can check that it works properly by looking at the generated rst file. Alternatively, we can translate it to a basic html file using rst2html:
$ rst2html.py CIRM_Tutorial_1.rst CIRM_Tutorial_1.html
CIRM_Tutorial_1.rst:176: (WARNING/2) Explicit markup ends without a blank line; unexpected unindent.
CIRM_Tutorial_1.rst:334: (WARNING/2) Inline strong start-string without end-string.
As seen above, there are few warnings sometimes because the translation made by sws2rst is not 100% perfect, but most of it is okay:
$ firefox CIRM_Tutorial_1.html
Moreover, one can use the sage -rst2ipynb script (installed with `sage -i rst2ipynb` + you may need to install `pandoc` on the system) to translate the rst file obtained above to a Jupyter notebook:
$ sage -rst2ipynb CIRM_Tutorial_1.rst CIRM_Tutorial_1.ipynb
One can check the result:
$ sage -n jupyter
(This answer was copy-pasted from the [ReleaseTour of Sage-9.2](https://wiki.sagemath.org/ReleaseTours/sage-9.2#sws2rst_.2B-_usage_example))
Note that to translate old .sws files to .ipynb, you may also use the export notebook:
$ sage -n -h
[...]
* List available legacy Sage notebooks:
sage --notebook=export --list
* Export a legacy Sage notebook as a Jupyter notebook:
sage --notebook=export --ipynb=Output.ipynb admin:10Mon, 09 Nov 2020 03:17:49 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?answer=54174#post-id-54174Comment by tmonteil for <p>Since sagemath-9.2 (see ticket <a href="https://trac.sagemath.org/ticket/28838">#28838</a>), the command <code>sage -sws2rst</code> was resurrected via a new pip-installable package sage-sws2rst. It can be installed in Sage 9.2 using <code>sage -i sage_sws2rst</code>. </p>
<p>Below is an example of usage. First we download a sage worksheet (.sws) prepared for Sage Days 20 at CIRM (Marseille, 2010):</p>
<pre><code>$ wget http://slabbe.org/Sage/2010-perpignan/CIRM_Tutorial_1.sws
$ ls
CIRM_Tutorial_1.sws
</code></pre>
<p>We translate the sws worksheet into a ReStructuredText syntax file (.rst) using sage -sws2rst. This creates also a directory of images:</p>
<pre><code>$ sage -sws2rst CIRM_Tutorial_1.sws
Processing CIRM_Tutorial_1.sws
File at CIRM_Tutorial_1.rst
Image directory at CIRM_Tutorial_1_media
$ ls
CIRM_Tutorial_1_media CIRM_Tutorial_1.rst CIRM_Tutorial_1.sws
</code></pre>
<p>Then, we can check that it works properly by looking at the generated rst file. Alternatively, we can translate it to a basic html file using rst2html:</p>
<pre><code>$ rst2html.py CIRM_Tutorial_1.rst CIRM_Tutorial_1.html
CIRM_Tutorial_1.rst:176: (WARNING/2) Explicit markup ends without a blank line; unexpected unindent.
CIRM_Tutorial_1.rst:334: (WARNING/2) Inline strong start-string without end-string.
</code></pre>
<p>As seen above, there are few warnings sometimes because the translation made by sws2rst is not 100% perfect, but most of it is okay:</p>
<pre><code>$ firefox CIRM_Tutorial_1.html
</code></pre>
<p>Moreover, one can use the sage -rst2ipynb script (installed with <code>sage -i rst2ipynb</code> + you may need to install <code>pandoc</code> on the system) to translate the rst file obtained above to a Jupyter notebook:</p>
<pre><code>$ sage -rst2ipynb CIRM_Tutorial_1.rst CIRM_Tutorial_1.ipynb
</code></pre>
<p>One can check the result:</p>
<pre><code>$ sage -n jupyter
</code></pre>
<p>(This answer was copy-pasted from the <a href="https://wiki.sagemath.org/ReleaseTours/sage-9.2#sws2rst_.2B-_usage_example">ReleaseTour of Sage-9.2</a>)</p>
<p>Note that to translate old .sws files to .ipynb, you may also use the export notebook:</p>
<pre><code>$ sage -n -h
[...]
* List available legacy Sage notebooks:
sage --notebook=export --list
* Export a legacy Sage notebook as a Jupyter notebook:
sage --notebook=export --ipynb=Output.ipynb admin:10
</code></pre>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=54180#post-id-54180OK thanks. Since this question arise quite often, if it is not working on windows, i am thinking about offering a web service that does the translation online.Mon, 09 Nov 2020 12:24:27 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=54180#post-id-54180Comment by Sébastien for <p>Since sagemath-9.2 (see ticket <a href="https://trac.sagemath.org/ticket/28838">#28838</a>), the command <code>sage -sws2rst</code> was resurrected via a new pip-installable package sage-sws2rst. It can be installed in Sage 9.2 using <code>sage -i sage_sws2rst</code>. </p>
<p>Below is an example of usage. First we download a sage worksheet (.sws) prepared for Sage Days 20 at CIRM (Marseille, 2010):</p>
<pre><code>$ wget http://slabbe.org/Sage/2010-perpignan/CIRM_Tutorial_1.sws
$ ls
CIRM_Tutorial_1.sws
</code></pre>
<p>We translate the sws worksheet into a ReStructuredText syntax file (.rst) using sage -sws2rst. This creates also a directory of images:</p>
<pre><code>$ sage -sws2rst CIRM_Tutorial_1.sws
Processing CIRM_Tutorial_1.sws
File at CIRM_Tutorial_1.rst
Image directory at CIRM_Tutorial_1_media
$ ls
CIRM_Tutorial_1_media CIRM_Tutorial_1.rst CIRM_Tutorial_1.sws
</code></pre>
<p>Then, we can check that it works properly by looking at the generated rst file. Alternatively, we can translate it to a basic html file using rst2html:</p>
<pre><code>$ rst2html.py CIRM_Tutorial_1.rst CIRM_Tutorial_1.html
CIRM_Tutorial_1.rst:176: (WARNING/2) Explicit markup ends without a blank line; unexpected unindent.
CIRM_Tutorial_1.rst:334: (WARNING/2) Inline strong start-string without end-string.
</code></pre>
<p>As seen above, there are few warnings sometimes because the translation made by sws2rst is not 100% perfect, but most of it is okay:</p>
<pre><code>$ firefox CIRM_Tutorial_1.html
</code></pre>
<p>Moreover, one can use the sage -rst2ipynb script (installed with <code>sage -i rst2ipynb</code> + you may need to install <code>pandoc</code> on the system) to translate the rst file obtained above to a Jupyter notebook:</p>
<pre><code>$ sage -rst2ipynb CIRM_Tutorial_1.rst CIRM_Tutorial_1.ipynb
</code></pre>
<p>One can check the result:</p>
<pre><code>$ sage -n jupyter
</code></pre>
<p>(This answer was copy-pasted from the <a href="https://wiki.sagemath.org/ReleaseTours/sage-9.2#sws2rst_.2B-_usage_example">ReleaseTour of Sage-9.2</a>)</p>
<p>Note that to translate old .sws files to .ipynb, you may also use the export notebook:</p>
<pre><code>$ sage -n -h
[...]
* List available legacy Sage notebooks:
sage --notebook=export --list
* Export a legacy Sage notebook as a Jupyter notebook:
sage --notebook=export --ipynb=Output.ipynb admin:10
</code></pre>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=54178#post-id-54178The 9.2 windows installer is not yet available at https://github.com/sagemath/sage-windows/releases
I will ask a colleague running windows to test it when it will be available.Mon, 09 Nov 2020 09:29:51 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=54178#post-id-54178Comment by tmonteil for <p>Since sagemath-9.2 (see ticket <a href="https://trac.sagemath.org/ticket/28838">#28838</a>), the command <code>sage -sws2rst</code> was resurrected via a new pip-installable package sage-sws2rst. It can be installed in Sage 9.2 using <code>sage -i sage_sws2rst</code>. </p>
<p>Below is an example of usage. First we download a sage worksheet (.sws) prepared for Sage Days 20 at CIRM (Marseille, 2010):</p>
<pre><code>$ wget http://slabbe.org/Sage/2010-perpignan/CIRM_Tutorial_1.sws
$ ls
CIRM_Tutorial_1.sws
</code></pre>
<p>We translate the sws worksheet into a ReStructuredText syntax file (.rst) using sage -sws2rst. This creates also a directory of images:</p>
<pre><code>$ sage -sws2rst CIRM_Tutorial_1.sws
Processing CIRM_Tutorial_1.sws
File at CIRM_Tutorial_1.rst
Image directory at CIRM_Tutorial_1_media
$ ls
CIRM_Tutorial_1_media CIRM_Tutorial_1.rst CIRM_Tutorial_1.sws
</code></pre>
<p>Then, we can check that it works properly by looking at the generated rst file. Alternatively, we can translate it to a basic html file using rst2html:</p>
<pre><code>$ rst2html.py CIRM_Tutorial_1.rst CIRM_Tutorial_1.html
CIRM_Tutorial_1.rst:176: (WARNING/2) Explicit markup ends without a blank line; unexpected unindent.
CIRM_Tutorial_1.rst:334: (WARNING/2) Inline strong start-string without end-string.
</code></pre>
<p>As seen above, there are few warnings sometimes because the translation made by sws2rst is not 100% perfect, but most of it is okay:</p>
<pre><code>$ firefox CIRM_Tutorial_1.html
</code></pre>
<p>Moreover, one can use the sage -rst2ipynb script (installed with <code>sage -i rst2ipynb</code> + you may need to install <code>pandoc</code> on the system) to translate the rst file obtained above to a Jupyter notebook:</p>
<pre><code>$ sage -rst2ipynb CIRM_Tutorial_1.rst CIRM_Tutorial_1.ipynb
</code></pre>
<p>One can check the result:</p>
<pre><code>$ sage -n jupyter
</code></pre>
<p>(This answer was copy-pasted from the <a href="https://wiki.sagemath.org/ReleaseTours/sage-9.2#sws2rst_.2B-_usage_example">ReleaseTour of Sage-9.2</a>)</p>
<p>Note that to translate old .sws files to .ipynb, you may also use the export notebook:</p>
<pre><code>$ sage -n -h
[...]
* List available legacy Sage notebooks:
sage --notebook=export --list
* Export a legacy Sage notebook as a Jupyter notebook:
sage --notebook=export --ipynb=Output.ipynb admin:10
</code></pre>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=54177#post-id-54177Does this works under windows ?Mon, 09 Nov 2020 07:15:08 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=54177#post-id-54177Answer by slelievre for <p>Hi All,</p>
<p>I downloaded several SageMath files with extension sws, but I am unable to open them with SageMath 8.0 on Windows native. Is there any translator from sws to ipynb file? How should I proceed?</p>
<p>Thanks,</p>
<p>Daniel</p>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?answer=41169#post-id-41169# Convert SageNB (.sws) worksheets to Jupyter (.ipynb) worksheets
There are several ways to go, depending on whether you want to convert SageNB worksheets
from your SageNB collection (they live in the .sage folder in your home folder), or .sws files
that exist elsewhere in your filesystem.
For a SageNB .sws worksheet located somewhere visible in your file system, you could
convert it to reStructuredText (.rst) using `sws2rst`and then convert the .rst file to
a Jupyter .ipynb worksheet with `rst-to-ipynb`.
Or you could upload it to your SageNB collection, as indicated by @Iguananaut
(run `sage -n sagenb`, upload the .sws files to your SageNB collection), then use
the exporter (launch it by running `sage -n export` in a terminal) which will offer
to export all SageNB worksheets in your SageNB collection to Jupyter worksheets.
Sun, 18 Feb 2018 00:36:57 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?answer=41169#post-id-41169Comment by danielvolinski for <h1>Convert SageNB (.sws) worksheets to Jupyter (.ipynb) worksheets</h1>
<p>There are several ways to go, depending on whether you want to convert SageNB worksheets
from your SageNB collection (they live in the .sage folder in your home folder), or .sws files
that exist elsewhere in your filesystem.</p>
<p>For a SageNB .sws worksheet located somewhere visible in your file system, you could
convert it to reStructuredText (.rst) using <code>sws2rst</code>and then convert the .rst file to
a Jupyter .ipynb worksheet with <code>rst-to-ipynb</code>.</p>
<p>Or you could upload it to your SageNB collection, as indicated by <a href="/users/23374/iguananaut/">@Iguananaut</a>
(run <code>sage -n sagenb</code>, upload the .sws files to your SageNB collection), then use
the exporter (launch it by running <code>sage -n export</code> in a terminal) which will offer
to export all SageNB worksheets in your SageNB collection to Jupyter worksheets.</p>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=41174#post-id-41174Sorry, I meant "I can't select any file"Sun, 18 Feb 2018 13:01:51 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=41174#post-id-41174Comment by danielvolinski for <h1>Convert SageNB (.sws) worksheets to Jupyter (.ipynb) worksheets</h1>
<p>There are several ways to go, depending on whether you want to convert SageNB worksheets
from your SageNB collection (they live in the .sage folder in your home folder), or .sws files
that exist elsewhere in your filesystem.</p>
<p>For a SageNB .sws worksheet located somewhere visible in your file system, you could
convert it to reStructuredText (.rst) using <code>sws2rst</code>and then convert the .rst file to
a Jupyter .ipynb worksheet with <code>rst-to-ipynb</code>.</p>
<p>Or you could upload it to your SageNB collection, as indicated by <a href="/users/23374/iguananaut/">@Iguananaut</a>
(run <code>sage -n sagenb</code>, upload the .sws files to your SageNB collection), then use
the exporter (launch it by running <code>sage -n export</code> in a terminal) which will offer
to export all SageNB worksheets in your SageNB collection to Jupyter worksheets.</p>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=41173#post-id-41173As I mentioned in the comment to the first answer, the sws2rst command did not work for me.
Moreover the `sage -n sagenb` and `sage -n export` open a window but there is no list of files to be translated to the new format so I can select any file.
And another question: I found SageMath files with extension *.sagews, how to translate those?
I found several old extensions of SageMath: *.sage, *.sagews, *.sws. Are there more?
I'm working with SageMath 8.1 on Windows 10 Native.
Thanks,
DanielSun, 18 Feb 2018 13:01:07 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=41173#post-id-41173Answer by Iguananaut for <p>Hi All,</p>
<p>I downloaded several SageMath files with extension sws, but I am unable to open them with SageMath 8.0 on Windows native. Is there any translator from sws to ipynb file? How should I proceed?</p>
<p>Thanks,</p>
<p>Daniel</p>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?answer=40156#post-id-40156To be clear, this isn't anything specific to Windows. The `.sws` worksheets are for the legacy [Sage Notebook](http://doc.sagemath.org/html/en/reference/notebook/index.html) software, that is largely being supplanted by the [Jupyter Notebook](http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html) which is what the Windows version provides by default.
You can still run the legacy notebook from the command-line by running the "SageMath Shell" and entering
sage -notebook=sagenb
Enter whatever you want for the "admin password" (It's not important; this is just a legacy of its original design to be a multi-user system). Then I think you have to actually "Upload" the sws files into the Notebook server; it doesn't allow you to directly browse the local filesystem.
This will allow you to quickly use those files, but I would suggest trying to convert them to the ipynb format as discussed in this question: https://ask.sagemath.org/question/35873/how-to-automatically-convert-many-sws-to-ipynb/Thu, 14 Dec 2017 06:01:04 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?answer=40156#post-id-40156Comment by eric_g for <p>To be clear, this isn't anything specific to Windows. The <code>.sws</code> worksheets are for the legacy <a href="http://doc.sagemath.org/html/en/reference/notebook/index.html">Sage Notebook</a> software, that is largely being supplanted by the <a href="http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html">Jupyter Notebook</a> which is what the Windows version provides by default.</p>
<p>You can still run the legacy notebook from the command-line by running the "SageMath Shell" and entering</p>
<pre><code>sage -notebook=sagenb
</code></pre>
<p>Enter whatever you want for the "admin password" (It's not important; this is just a legacy of its original design to be a multi-user system). Then I think you have to actually "Upload" the sws files into the Notebook server; it doesn't allow you to directly browse the local filesystem.</p>
<p>This will allow you to quickly use those files, but I would suggest trying to convert them to the ipynb format as discussed in this question: <a href="https://ask.sagemath.org/question/35873/how-to-automatically-convert-many-sws-to-ipynb/">https://ask.sagemath.org/question/358...</a></p>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=40226#post-id-40226For the conversion to ipynb, you should run `sage -n` and simply click on the name of your sws file, as it appears in the list "Convert old notebooks to Jupyter".Tue, 19 Dec 2017 03:51:30 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=40226#post-id-40226Comment by danielvolinski for <p>To be clear, this isn't anything specific to Windows. The <code>.sws</code> worksheets are for the legacy <a href="http://doc.sagemath.org/html/en/reference/notebook/index.html">Sage Notebook</a> software, that is largely being supplanted by the <a href="http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html">Jupyter Notebook</a> which is what the Windows version provides by default.</p>
<p>You can still run the legacy notebook from the command-line by running the "SageMath Shell" and entering</p>
<pre><code>sage -notebook=sagenb
</code></pre>
<p>Enter whatever you want for the "admin password" (It's not important; this is just a legacy of its original design to be a multi-user system). Then I think you have to actually "Upload" the sws files into the Notebook server; it doesn't allow you to directly browse the local filesystem.</p>
<p>This will allow you to quickly use those files, but I would suggest trying to convert them to the ipynb format as discussed in this question: <a href="https://ask.sagemath.org/question/35873/how-to-automatically-convert-many-sws-to-ipynb/">https://ask.sagemath.org/question/358...</a></p>
https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=40158#post-id-40158Hi iguananaut, I was able to access the files using the legacy sage, that is OK.
Regarding the conversion, it did not work for me. I used the following command:
sage -sws2rst riemann.sws riemann.rst
It instructed me to install BeautifulSoup which I did with the following command
easy_install BeautifulSoup
I then proceeded to use the same convert command above and got:
('Processing', 'riemann.sws')
bunch of stuff ...
OSError: [Errno 13] Permission denied: '/tmp/tmp8zq48e/sage_worksheet/cells'
What should I do now?Thu, 14 Dec 2017 07:18:30 -0600https://ask.sagemath.org/question/40136/file-with-extension-sws/?comment=40158#post-id-40158