= SageMath on Windows = To run Sage on Windows, use Windows Subsystem for Linux as documented in the [[https://deploy-livedoc--sagemath.netlify.app/html/en/installation/index.html|Sage Installation Guide]]. ==== Viewing 2D/3D plots from the WSL command line in a Windows browser ==== If you want to use your Windows browser to view 2D/3D plots produced from the Sage command-line in WSL, you will need to first create a small wrapper script to translate a WSL path into a Windows path and open it with the appropriate Windows app: {{{#!highlight bash #!/bin/bash # wslview_wslpath.sh wslview $(wslpath -w $1) }}} Make sure it is executable. Assuming you placed it in your home folder: {{{#!highlight bash chmod +x /home//wslview_wslpath.sh }}} Now, add the following to your [[https://doc.sagemath.org/html/en/reference/repl/startup.html#the-init-sage-script|init.sage]]: {{{#!highlight python # Open 2D/3D plots in Windows browser. wslview_wslpath = '/home//wslview_wslpath.sh' from sage.misc.viewer import viewer viewer.browser(wslview_wslpath) # for 3D plots viewer.png_viewer(wslview_wslpath) # for 2D plots # Uncomment these lines to also open DVIs and PDFs in Windows. #viewer.dvi_viewer(wslview_wslpath) #viewer.pdf_viewer(wslview_wslpath) # The Windows browser will be unable to access the threejs library installed # in WSL, so you will need to use the online version of threejs. sage.plot.plot3d.base.SHOW_DEFAULTS['online'] = True }}} ==== Launching Jupyter/JupyterLab from WSL in the Windows browser ==== If you want to launch Jupyter/JupyterLab in your Windows browser, you will need to make a small config change. First, [[https://jupyter-notebook.readthedocs.io/en/stable/config.html|generate a config file]] if you haven't already done so using one of: {{{#!highlight bash sage --jupyter notebook --generate-config sage --jupyter lab --generate-config }}} Then, open the config file and make sure the option `use_redirect_file` is set to `False`: {{{#!highlight python c.NotebookApp.use_redirect_file = False }}} === CoCalc === [[https://cocalc.com/|CoCalc]] (formerly SageMathCloud) is a collaborative cloud-based computing environment, originally designed for using Sage in the cloud. Through CoCalc you can run Sage either in its command-line interface, or in a Jupyter Notebook, all through your web browser on a cloud-hosted environment, meaning you don't have to install any software (other than a web browser), but that you also need an internet connection. CoCalc was originally designed by William Stein, the creator of Sage, to run Sage in the cloud (back when it was called SageMathCloud), but it was quickly realized that all the infrastructure needed to run Sage on the cloud can also be used for a more generic scientific computing environment, which the re-branded CoCalc now provides. You can see some of the software provided by a CoCalc environment [[https://cocalc.com/doc/software.html|here]]. You can create an unlimited account for free, though the free accounts are limited in the amount of disk space they provide, and the amount of RAM they provide. They also do not allow direct internet access from within the CoCalc environment (but you are allowed to upload your data files through the CoCalc interface). See https://cocalc.com/policies/pricing.html for more details. Sometimes William will also provide discounts for specific academic purposes, or for people who are willing to contribute to CoCalc's [[https://github.com/sagemathinc/cocalc|development]], though we cannot speak for him here. As long as you have reasonably reliable internet connection, CoCalc is a great way to just try out Sage, and other open-source mathematics software, without having to go to the trouble of installing anything on your local machine. However, with a flaky or overloaded internet connection, it can sometimes be slow and frustrating.