Opened 2 years ago

Closed 10 days ago

#30484 closed enhancement (fixed)

Document using Sage on Windows via Visual Studio Code with WSL remote

Reported by: mkoeppe Owned by:
Priority: critical Milestone: sage-9.7
Component: user interface Keywords:
Cc: gh-tobiasdiez, charpent, tmonteil, kcrisman, gh-louisng, klee, tscrim, slelievre Merged in:
Authors: Louis Ng, Matthias Koeppe Reviewers: Tobias Diez, Kwankyu Lee
Report Upstream: N/A Work issues:
Branch: 79552c6 (Commits, GitHub, GitLab) Commit: 79552c66bcabdbc76caf00e404ac02e284835893
Dependencies: #33131, #33103 Stopgaps:

Status badges

Description (last modified by klee)

We already have a basic VS Code configuration; #33103 makes some minor updates.

In this ticket, we add documentation for installing VS Code on Windows and setting up the WSL remote, as the primary way how to use Sage on Windows. This goes to

Next task: cross reference it from the developer's guide and add information there on how to develop Sage on Windows.

References:

Attachments (1)

Screenshot 2022-04-08 201448.png (22.9 KB) - added by gh-tobiasdiez 4 months ago.

Download all attachments as: .zip

Change History (44)

comment:1 follow-up: Changed 2 years ago by gh-tobiasdiez

A basic how to setup VS code for sage (from https://trac.sagemath.org/ticket/25206#comment:63):

comment:2 Changed 2 years ago by mkoeppe

Should also add instructions for cygwin shell under VS code; random link - https://superuser.com/questions/1511487/cygwin-shell-in-vs-code-tries-to-activate-conda-how-to-prevent-this

comment:3 Changed 22 months ago by mkoeppe

  • Milestone changed from sage-9.2 to sage-9.3

comment:4 in reply to: ↑ 1 Changed 22 months ago by dimpase

Replying to gh-tobiasdiez:

  • Use ./sage -br to trigger a rebuild of sage.

I'd suggest make build && ./sage instead.

comment:5 Changed 17 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.

comment:6 Changed 12 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:7 Changed 11 months ago by mkoeppe

  • Dependencies set to #30677

comment:8 Changed 8 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:9 Changed 7 months ago by mkoeppe

  • Summary changed from Visual Studio (vscode) configuration to Documentation/configuration for Visual Studio (vscode) with a WSL remote

comment:10 Changed 7 months ago by mkoeppe

  • Cc charpent tmonteil kcrisman added
  • Dependencies changed from #30677 to #33131, #33103
  • Description modified (diff)
  • Summary changed from Documentation/configuration for Visual Studio (vscode) with a WSL remote to Documentation/configuration for Sage on Windows using Visual Studio (vscode) with a WSL remote

comment:11 Changed 4 months ago by dimpase

Hmm, I can't figure out how to use vscode with a Sage notebook. The problem is to get vscode to find the correct kernel...

comment:12 follow-up: Changed 4 months ago by gh-tobiasdiez

At least for a "normal" jupyter notebook, selecting the venv created by sage worked for me.

There is also the possibility to connect to a "remote" jupyter instance. https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_connect-to-a-remote-jupyter-server So if you start sage's jupyter server, you should be able to connect to it in this way.

comment:13 in reply to: ↑ 12 Changed 4 months ago by dimpase

Replying to gh-tobiasdiez:

At least for a "normal" jupyter notebook, selecting the venv created by sage worked for me.

The question is, how does vscode's jupyter discover kernels? Where? What should be set?

There is also the possibility to connect to a "remote" jupyter instance. https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_connect-to-a-remote-jupyter-server So if you start sage's jupyter server, you should be able to connect to it in this way.

Changed 4 months ago by gh-tobiasdiez

comment:14 follow-up: Changed 4 months ago by gh-tobiasdiez

In the upper right corner you can select the kernel/python version, see attached screenshot.

comment:15 Changed 4 months ago by mkoeppe

  • Cc gh-louisng added

comment:16 Changed 4 months ago by gh-louisng114

comment:17 Changed 4 months ago by mkoeppe

Not sure if it has just moved or this is a different document: https://code.visualstudio.com/docs/remote/wsl

comment:19 in reply to: ↑ 14 Changed 4 months ago by dimpase

Replying to gh-tobiasdiez:

In the upper right corner you can select the kernel/python version, see attached screenshot.

it's rather unpredictable whether Sage jupyter kernel will be available. Often it's just not there. Perhaps it needs to installed to a specific location.

Last edited 4 months ago by dimpase (previous) (diff)

comment:20 Changed 4 months ago by mkoeppe

  • Description modified (diff)

comment:22 Changed 4 months ago by gh-louisng114

  • Branch set to public/30484
  • Commit set to 8a4eb057f90f1147d20a823f2d6461d8dfb7459c

comment:23 Changed 4 months ago by mkoeppe

  • Authors set to Louis Ng
  • Status changed from new to needs_review

comment:24 Changed 4 months ago by gh-tobiasdiez

  • Reviewers set to Tobias Diez
  • Status changed from needs_review to needs_work

The changes mostly look good to me, but I think the ticket originally had a broader scope than only the configuration for Jupiter notebooks.

Moreover, according to https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette Ctrl + Shift + P is the default/recommended shortcut to open the command palette. Maybe rephrase this part as In the command palette (Ctrl + Shift + P), choose "xyz"?

comment:25 follow-up: Changed 4 months ago by git

  • Commit changed from 8a4eb057f90f1147d20a823f2d6461d8dfb7459c to 6881dd6e7ee964603a40b32e243538877e1d0aee

Branch pushed to git repo; I updated commit sha1. New commits:

6881dd6Changed phrasing regarding the command palette

comment:26 Changed 4 months ago by mkoeppe

On macOS, its Cmd + Shift + P. Perhaps also include the link to the VS Code documentation?

comment:27 in reply to: ↑ 25 Changed 4 months ago by gh-tobiasdiez

Replying to git:

Branch pushed to git repo; I updated commit sha1. New commits:

6881dd6Changed phrasing regarding the command palette

Thanks!

comment:28 Changed 4 months ago by mkoeppe

  • Priority changed from major to critical

comment:29 Changed 4 months ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7

comment:30 Changed 2 weeks ago by git

  • Commit changed from 6881dd6e7ee964603a40b32e243538877e1d0aee to b0c907eeb502b43be3bc63423b8989efa776f8cc

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

b29ccb9added VC Code WSL Jupyter section
8389ebcChanged phrasing regarding the command palette
b0c907esrc/doc/en/installation/launching.rst: Add markup for key chords

comment:31 Changed 2 weeks ago by mkoeppe

  • Status changed from needs_work to needs_review

comment:32 Changed 2 weeks ago by mkoeppe

  • Cc klee added

comment:33 Changed 12 days ago by mkoeppe

  • Cc tscrim slelievre added

comment:34 Changed 12 days ago by klee

I am new to the Visual Studio Code interface to the sagemath installed in WSL.

I followed the guide of the branch of this ticket. It mostly worked.

But in the first attempt, I could not select SageMath kernel in the jupyter notebook. It was simply missing.

I wandered around for some time, and then found Jupyter Extension in the Extensions panel. I installed it, and did the ":Create: New Jupyter Notebook" thing again. Then I could finally select SageMath kernel.

So it seems that there is a missing step in the guide: "Install Jupyter Extension"

Anyway, this VSCode interface to sage is very nice!

Still it was not straightforward for me to setup the working jupyter notebook with sagemath kernel starting from building sage from source in WSL.

comment:35 follow-up: Changed 12 days ago by mkoeppe

Thanks for testing it! I'll add this step

comment:36 Changed 12 days ago by git

  • Commit changed from b0c907eeb502b43be3bc63423b8989efa776f8cc to 79552c66bcabdbc76caf00e404ac02e284835893

Branch pushed to git repo; I updated commit sha1. New commits:

79552c6src/doc/en/installation/launching.rst: Also mention Jupyter Extension

comment:37 Changed 12 days ago by mkoeppe

  • Authors changed from Louis Ng to Louis Ng, Matthias Koeppe

comment:38 in reply to: ↑ 35 Changed 12 days ago by klee

  • Reviewers changed from Tobias Diez to Tobias Diez, Kwankyu Lee
  • Status changed from needs_review to positive_review

Replying to mkoeppe:

Thanks for testing it! I'll add this step

Thanks. It looks good to me.

comment:39 Changed 12 days ago by klee

  • Summary changed from Documentation/configuration for Sage on Windows using Visual Studio (vscode) with a WSL remote to Documentation for Sage on Windows using Visual Studio (vscode) with WSL remote

comment:40 Changed 12 days ago by klee

  • Summary changed from Documentation for Sage on Windows using Visual Studio (vscode) with WSL remote to Document using Sage on Windows via Visual Studio Code with WSL remote

comment:41 Changed 12 days ago by klee

  • Description modified (diff)

comment:42 Changed 12 days ago by mkoeppe

Thanks!

comment:43 Changed 10 days ago by vbraun

  • Branch changed from public/30484 to 79552c66bcabdbc76caf00e404ac02e284835893
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.