Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run jupyter kernel using python extension #3874

Closed
simeneide opened this issue Jul 29, 2021 · 43 comments · Fixed by #4231
Closed

Cannot run jupyter kernel using python extension #3874

simeneide opened this issue Jul 29, 2021 · 43 comments · Fixed by #4231
Assignees
Labels
bug Something isn't working high-priority This issue needs to be resolved ASAP

Comments

@simeneide
Copy link

simeneide commented Jul 29, 2021

I upgraded to the latest code-server today and now the jupyter interactive functionality of the python extension has stopped working. This happens both when I did this using a remote linux machine (docker based on the pytorch 1.9 image), AND when installing code-server on my local macbook. When opening a jupyter notebook a popup with the following information appears:

Command 'Jupyter: Create New Blank Notebook' resulted in an error (command 'jupyter.createnewnotebook' not found)

OS/Web Information

  • Web Browser: brave
  • Local OS: macOs
  • Remote OS: macos
  • Remote Architecture:
  • code-server --version: 3.11.0 4e8cd09

Steps to Reproduce

On macos (m1):

  1. install code-server using install script

  2. install python extension (ms-python.python v2021.7.1060902895). This will also install a jupyter extension (ms-toolsai.jupyter v2021.6.832593372)
    image

  3. Try to open a new jupyter notebook (cmd+shift+p "Jupyter: Create new Blank Notebook")
    image
    image

The developer console has this error (which is too far in the deep for me to understand):
image

Expected

A jupyter notebook starts up

Actual

Error message
Command 'Jupyter: Create New Blank Notebook' resulted in an error (command 'jupyter.createnewnotebook' not found)

@jsjoeio jsjoeio added the needs-investigation This issue needs to be further investigated label Jul 29, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented Jul 29, 2021

Thanks for opening the issue! I have never used jupyter notebooks.

Is it possible for you to update the repro steps? What do I need to install or how can I create a new jupyter notebook? Then I can try to reproduce locally and see how we can help you.

Thanks!

@simeneide
Copy link
Author

Is it possible for you to update the repro steps? What do I need to install or how can I create a new jupyter notebook? Then I can try to reproduce locally and see how we can help you.

Updated, thanks for coming back to me :) I thought "everyone" had this workflow, because it is such a good one ;)

@jsjoeio
Copy link
Contributor

jsjoeio commented Jul 30, 2021

Thanks @simeneide for working with me (Python/Jupyter noob here). That was very easy to follow and I received the same error as you.

I can't promise when we will get to this but I will add it to the next cycle and label it as high-priority.

Video

(Apologies in advance if I pronounced your name wrong)

Screen.Recording.2021-07-30.at.10.40.27.AM.mov

@jsjoeio jsjoeio added bug Something isn't working high-priority This issue needs to be resolved ASAP and removed needs-investigation This issue needs to be further investigated labels Jul 30, 2021
@jsjoeio jsjoeio added this to the 3.12.0 milestone Jul 30, 2021
@balajib-b
Copy link

@simeneide the installed jupyter extension facilitates VS Code to interface with jupyter package installed in your env, it doesnt install jupyter notebook to your current environment. I would be happy if you could confirm that the python environment you are using has got jupyter installed.
Open terminal and type "python -m pip list" and check jupyter notebook and its dependent packages are installed. i have been using mixed stack of code server, jupyter, miniconda, pytorch, tensorflow with no issues.
Also requesting you to use latest version of code server.

@simeneide
Copy link
Author

Yes, all has and I am also able to start jupyter notebook. Currently using 3.11.0 as that is the latest found in brew (which is used when installing with the script). However, it fails much before it starts connecting to the jupyter kernel (as seen in video), so unsure if this is the problem. Are you not able to reproduce my steps? Alternatively, can you provide a step-by-step of how you get your setup to work?

Also: My steps above are working on 3.10, so something has happened.

@balajib-b
Copy link

@simeneide i doubt whether your jupyter installation is in path. there could be few more possibilities pertaining to this error. ping me at ji.balajib[at]gmail.com lets connect remote and debug. Im happy to help

i think this way its going to be quick and then post back solution here. this could help @jsjoeio close few more issues.

@gogobd
Copy link

gogobd commented Aug 15, 2021

I have the very same problem in 3.11.1 and all previous versions. My last working configuration is code-server-3.9.3-linux-amd64. It would be great if Jupyter Notebooks could be fixed in current versions.

#3776
#3782
#2741

@jsjoeio
Copy link
Contributor

jsjoeio commented Aug 16, 2021

Thanks for the notes @gogobd!

It would be great if Jupyter Notebooks could be fixed in current versions.

It's in the next milestone (3.12) so it will get worked on soon and should come in the next version. We have a couple competing priorities and an off-site this week so I can't promise when but keep an eye out!

@simeneide
Copy link
Author

Do you know what is missing, @jsjoeio? Otherwise I am pretty sure I can cook up a simple docker image to reproduce this so that you can have a look, @balajib-b.

@jsjoeio
Copy link
Contributor

jsjoeio commented Aug 16, 2021

I think I just need to dig into VS Code and figure out where jupyter.createnewnotebook is defined. I found it here and it's here in code-server. But the name is vscode-notebook-tests 🤔 I'd have to look closer at what's happening.

I'm not too familiar with how native VS Code commands/extensions get loaded but I'm guessing the issue lies there.

So maybe it's not being included in code-server's latest version for some reason 🤔 @code-asher may have some pro tips for debugging too, but this is where I would start.

(Thanks for asking and offering to help though @simeneide super appreciated ♥️)

@balajib-b
Copy link

Do you know what is missing, @jsjoeio? Otherwise I am pretty sure I can cook up a simple docker image to reproduce this so that you can have a look, @balajib-b.

that would be sufficient @simeneide , send me the yaml.

@im-coder-lg
Copy link
Contributor

Have you tried Anaconda3 and Jupyter built inside Anaconda3?

@dthompson-maystreet
Copy link

@stefano can you provide any hints here, perhaps? You managed to get Jupyter running inside code-server successfully (though with a couple of issues - [#4013]

@sdissegna-maystreet
Copy link
Contributor

Slightly older versions of the vscode-python and vscode-jupyter, i.e. the latest versions still compatible with vscode 1.57 seem to work out of the box.

@code-asher
Copy link
Member

code-asher commented Aug 23, 2021 via email

@fdasilva59
Copy link

Hi,

I am having the same issue with

  • code-server v3.11.1
  • VS Code v1.57.1
  • ms-python.python v2021.8.1159798656
  • Jupyter ms-toolsai v2021.6.99, v2021.5.0 (also 2021.8.2031173646 is not compatible with VS Code v1.57.1)
    (Note : I am also using an anaconda python environment, wher Jupyter is installed and is working fine)

=> Is there's somewhere a compatibility matrix of the code-server / VS Code / ms-toolsai versions to be used together and that are known to be functional ?

Thx !

@code-asher
Copy link
Member

code-asher commented Sep 2, 2021 via email

@benz0li
Copy link
Contributor

benz0li commented Sep 16, 2021

https://open-vsx.org/extension/ms-toolsai/jupyter/2021.8.12 plus https://open-vsx.org/extension/ms-python/python/2021.9.1218897484 are working fine with v3.12.0 on Debian 11 (Bullseye).

@gogobd
Copy link

gogobd commented Sep 16, 2021

Thank you, @benz0li for mentioning this here, I can confirm! I use docker to set up cdr code server and that's the first time in a long time this was working again:

## Code server
RUN mkdir -p ~/.local/lib ~/.local/bin
RUN curl -sfL https://github.com/cdr/code-server/releases/download/v3.12.0/code-server-3.12.0-linux-amd64.tar.gz | tar -C ~/.local/lib -xz
RUN mv ~/.local/lib/code-server-3.12.0-linux-amd64 ~/.local/lib/code-server-3.12.0
RUN ln -s ~/.local/lib/code-server-3.12.0/bin/code-server ~/.local/bin/code-server
RUN PATH="~/.local/bin:$PATH"

RUN curl -sfLO https://open-vsx.org/api/ms-toolsai/jupyter/2021.8.12/file/ms-toolsai.jupyter-2021.8.12.vsix \
 && curl -sfLO https://open-vsx.org/api/ms-python/python/2021.9.1218897484/file/ms-python.python-2021.9.1218897484.vsix \
 && ~/.local/bin/code-server --install-extension ./ms-toolsai.jupyter-2021.8.12.vsix || true \
 && ~/.local/bin/code-server --install-extension ./ms-python.python-2021.9.1218897484.vsix || true \
 && rm ms-toolsai.jupyter-2021.8.12.vsix \
 && rm ms-python.python-2021.9.1218897484.vsix

@jtcole
Copy link

jtcole commented Sep 18, 2021

i just installed 3.12 clean (deleted all cache and configs) and still have the issue on ubuntu 20.04 lts.

@simeneide
Copy link
Author

Again, thanks for looking into this. Although many similar comments, I can neither get this to work for 3.12.

@edvincent
Copy link
Contributor

Here's a matrix table with links for those who want it working. The bottomline being: you can't use marketplace from code-server itself. You either need to manually download, drag-and-drop and install; or do something equivalent.

code-server vscode ms-python.python ms-toolsai.jupyter
3.11.0 1.57 v2021.8.1159798656
Installing from code-server's default marketplace: ✅
Open VSX Download
GtiHub Download
v2021.6.9999
Installing from code-server's default marketplace: ❌
GitHub build artifact from microsoft/vscode-jupyter
3.11.1 1.57.1 v2021.8.1159798656
Installing from code-server's default marketplace: ✅
Open VSX Download
GtiHub Download
v2021.6.9999
Installing from code-server's default marketplace: ❌
GitHub build artifact from microsoft/vscode-jupyter
3.12 1.60 2021.9.1218897484
Installing from code-server's default marketplace: ✅
Open VSX Download
GitHub Download
v2021.8.12
Installing from code-server's default marketplace: ❌
Open VSX Download
GitHub build artifact from microsoft/vscode-jupyter

@jsjoeio What's the best way to help here? Build a working version myself and send it over? Try and figure out how to edit the current command so the process starts working again? Can we make your scraper use the build artifacts from their CI/CD releases? Try to engage the maintainers to put the link directly to the VSIX in their releases? Can we re-upload to coder's marketplace the VSIX from Open VSX?

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 20, 2021

Thanks @edvincent for posting the matrix and offering to help! To be honest, the hardest part is finding time. I'm the only maintainer working full-time on code-server and I'm trying to juggle all the issues we have. My current priorities are improving the release process (see milestone).

I've added this issue there as well but haven't been able to dive in yet.

What's the best way to help here?

Thank you for asking that!

Well...we completely refactored how VS Code exists in the code-server codebase and it's in a funky place right now so it wouldn't be easy to get you into the codebase trying to edit the current command (we're lacking documentation cc @TeffenEllis).

Can we make your scraper use the build artifacts from their CI/CD releases?

Maybe? I'm not super familiar with this part of our codebase yet and haven't had time to dive in.

Try to engage the maintainers to put the link directly to the VSIX in their releases?

You could try this! I don't think we've had much success in the past though 😢

Can we re-upload to coder's marketplace the VSIX from Open VSX?

If you have a working vsix file that works with the latest version of code-server and send that over here, that might be easy then for me to upload it to our marketplace 🤔 (at least I'm hopefully it's a simple CLI command to upload, I think it should be).

Otherwise, hoping to dive in on this issue this week! Just gotta wrap up another thing

@benz0li
Copy link
Contributor

benz0li commented Sep 21, 2021

@edvincent Why not use the OpenVSX Registry by default? Sooner or later this will be the default anyway.

According to FAQ.md > How do I use my own extensions marketplace?:

export SERVICE_URL=https://open-vsx.org/vscode/gallery
export ITEM_URL=https://open-vsx.org/vscode/item

ℹ️ This is working fine for my builds.

@jsjoeio jsjoeio self-assigned this Sep 21, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 21, 2021

I'm going to start working on this issue and use this comment as a place to document my notes. I will update it as I find more information so as to not spam the issue.

Try to Reproduce Issue Locally

The first question is to see if this is still an issue. Here's how I'm going to try to reproduce it:

  1. using code-server 3.12.0, run code-server --extensions-dir cs-3874 (cs-3874 is the name of an empty directory. I do this so I start code-sever with no extensions installed, a clean slate.)
  2. Download the Python extension from Open VSX and manually install with .vsix file.
  3. Reload page in browser
  4. Verify both Python and Jupyter are installed: v2021.9.1230869389 and v2021.8.12 respectively
  5. Command Palette > Jupyter: Create New Blank Notebook

Expected

A jupyter notebook starts up

Actual

Command fails

image

✅ Confirmed. This issue still exists in code-server 3.12.0

Investigate Stack Trace

Based on the error in the console and the stack trace, it looks like we're missing a module in our fork of VS Code (you can tell because the stack points to vendor/modules/code-oss-dev which is where our fork of VS Code lives).

mainThreadExtensionService.ts:95 Activating extension 'ms-toolsai.jupyter' failed: Cannot find module '/Users/jp/Dev/repros/cs-3874/ms-toolsai.jupyter-2021.8.12/out/client/extension'
Require stack:
- /usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/vs/loader.js
- /usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/bootstrap-amd.js
- /usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/bootstrap-fork.js.

Well actually, It looks like it can't find the module in cs-3874/ms-toolsai.jupyter-2021.8.12/out/client/extension 🤔

Let's go there and take a look...

Well well JS, look who was right. There is no extension or client folder under out 🤔

image

Thinking out loud here...that means when the VSIX was published (19 hours ago), it didn't include all the build files, specifically the client which should be under out 🤔 But we do have this folder called client_renderer. Maybe if I change that to client, it will work? Let's give that a try...

  1. rename directory
cd cs-3874/ms-toolsai.jupyter-2021.8.12/out/
mv client_renderer client
  1. Reload code-server
  2. Command Palette > Jupyter: Create New Blank Notebook

Nope! Same issue. I checked the contents of client and realized it's a bunch of js files, but no extension file so of course that wouldn't work 🤦‍♂️

Compare Open VSX version to Release Asset version

Let's go look at the release assets from yesterday: https://github.com/microsoft/vscode-python/releases/tag/2021.9.1246542782 and download that vsix file.

We'll compare that to the one that we get from Open VSX to see if they're different or the same.

Okay so this won't work exactly because here's what happens:

  • you download the vsix file
  • rename ms-python.python-2021.9.1230869389.vsix to ms-python.python-2021.9.1230869389.zip
  • unzip folder

It only contains the Python extension which is open-source. What happens is you install this extension and it installs the extension pack which has Jupyter and Pylance (I assume both of those are closed-source).

Install Jupyter VSIX build artifact file

Wait, no, Jupyter is open-source? https://github.com/microsoft/vscode-jupyter/releases/tag/2021.8.12

I could have sworn it didn't use to be. Well the source code is published with the release so we could download, run the build scripts to output a vsix file.

Instead, I'm going to try downloading this vsix file from their build artifacts and trying that in code-server.

That doesn't work 😢

ERR Unable to install extension 'ms-toolsai.jupyter' as it is not compatible with VS Code '1.60.0'.: Error: Unable to install extension 'ms-toolsai.jupyter' as it is not compatible with VS Code '1.60.0'.
    at A.install (/usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/vs/server/entry.js:42:51324)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

(sidenote: I don't want to directly link the issue but it looks like this issue with the VSIX files has been raised in the Jupyter repo: microsoft _ vscode-jupyter _ issues_ 5582)

Picking up here: I'm cloning the vscode-jupyter repo and following the build steps.

I also want to look at the VS Code version 🤔 I think that error I got above is part of the reason why this won't work. code-server is running VS Code 1.60.0 and this version (or the latest version after cloning is: 1.61.0-insider

image

I wonder if we change that to 1.60.0, then rebuild and install in code-server if it will work.

It's interesting. They have this updateEngineToInsiders: https://github.com/microsoft/vscode-jupyter/blob/bd63750c91e6e23dacdfb99c24d88086e0d1acd4/build/ci/scripts/updateEngineToInsiders.js

Weird...if I search in the repo for this script, I don't find it used anywhere 🤔

image

Building vscode-jupyter from source and changing VS Code version to match code-server

That didn't work either! I was able to successfully install code-server but I ran into a new error

image

mainThreadExtensionService.ts:95 Activating extension 'vscode.ipynb' failed: Cannot find module '/usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/extensions/ipynb/dist/ipynbMain.js'
Require stack:
- /usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/vs/loader.js
- /usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/bootstrap-amd.js

I think this means we're going down the wrong rabbit hole. If you look at the stack-trace, it points back to code-oss-dev. And we know that VS Code bundles some extensions with it, including ipbynb which means we probably need to look there.

I think I'm going to check with @TeffenEllis to see if she has any ideas what might be causing these issues. There's some trickiness to working on code-oss-dev/our VS Code fork locally, but I think that's where I'll need to start looking.

Thanks for the patience everyone!

Reproduce in Gitpod's fork

The next step is to see if this issue can be reproduced in Gitpod's VS Code fork.

git clone https://github.com/gitpod-io/openvscode-server.git
yarn
yarn server:init
./resources/server/web.sh

Well, good news. It works in Gitpod 🤔

image

I'm going to guess then this issue is specific to code-server's fork of VS Code. At least we can look at Gitpod's fork and see where ours diverges.

I thought comparing would help but doesn't seem to tell us much 🤷‍♂️

coder/vscode@main...gitpod-io:main

Reproducing locally in code-server + cdr/vscode

# Make a directory with both projects
mkdir coder-oss && cd coder-oss

# Clone both repos
git clone https://github.com/cdr/code-server.git
git clone https://github.com/cdr/vscode.git

# Install dependencies in both
cd code-server && yarn install && cd ..
cd vscode && git checkout 1.60.0-code-server-patch && yarn install && cd ..

# Update code-server to point to local fork
cd code-server && cd vendor/modules
rm -r ./code-oss-dev
ls -s ../../../vscode ./code-oss-dev

# Run code-server 
# make sure you're in /code-server
cd ../../
yarn watch

Don't know if this is related. But inside Gitpod's, I see extensions/ipynb/out/ipynbMain.js exists. but for whatever reason, code-server is looking for that same file, but in extensions/ipynb/dist :thinking_face:

Both of them have the same package.json but my hunch tells me the Gitpod one is using main to find this extension build while ours is looking at browser

image

Ironically, I'm stuck trying to get code-server working with my local fork 😅

Okay...

I'm seeing this error

mainThreadExtensionService.ts:95 Activating extension 'vscode.ipynb' failed: Cannot find module '/usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/extensions/ipynb/dist/ipynbMain.js'
Require stack:
- /usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/vs/loader.js
- /usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/bootstrap-amd.js
- /usr/local/Cellar/code-server/3.12.0/libexec/vendor/modules/code-oss-dev/out/bootstrap-fork.js.

@benz0li
Copy link
Contributor

benz0li commented Sep 22, 2021

Wait, no, Jupyter is open-source? https://github.com/microsoft/vscode-jupyter/releases/tag/2021.8.12

@jsjoeio Yes. This issue has only been resolved recently by microsoft/vscode-jupyter#5812, which allowed updating both Python and Jupyter extensions on OpenVSX to a current version.
ℹ️ Don Jayamanne's Python extension had been stuck at version 2020.10.332292344 on OpenVSX for months due to its dependency on the Jupyter extension and the runtime license of the latter.

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 22, 2021

I installed with hombrew and we think the postinstall script isn't running which causes this.

GOOOD NEWS!! I'm on macOS and I installed code-server with the standalone method:

# install standalone method
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone

# Run code-server
~/.local/lib/code-server-3.12.0 --auth none

# install 2021.8.12 from Open VSX
# https://open-vsx.org/extension/ms-toolsai/jupyter/2021.8.12
# install extension into code-server

# Jupyter: Create new Blank Notebook

So this works!!!

image

We have narrowed down the error to the postinstall.sh script that is supposed to run after installing code-server locally. npm-postinstall.sh

We think it might be because we changed it from sh -> bash but we need to fix this (this was the only change)

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 22, 2021

Okay we figured it out by adding bash as a dependency to the homebrew formula and it works locally.

image

We should be running the postinstall with sh, but we made it run with bash because of Windows 🤔

Powershell doesn't have sh or bash by default 🤔 I think we need to revert this line until we can add proper Windows support, specifically revert this PR: #4116

Will discuss more tomorrow

jsjoeio added a commit that referenced this issue Sep 23, 2021
This reverts commit b32b4ed.

We are reverting this because we found out that while this fixes the postinstall
on Windows, it breaks it on mac and other devices.  See:
#3874 (comment)
@Craytor
Copy link

Craytor commented Sep 24, 2021

So should Jupyter now work after we update?

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 24, 2021

So should Jupyter now work after we update?

Once 3.12.1 is out, yes!

@im-coder-lg
Copy link
Contributor

im-coder-lg commented Sep 24, 2021 via email

@ucalyptus2
Copy link

I have a (kind of) idea. Why not install Anaconda3? That has Jupyter Notebook built-in, so you can create a notebook from that, right?

nopes boy, error persists.

@simeneide
Copy link
Author

nopes boy, error persists.

according to @jsjoeio this will be fixed in 3.13 (separate issue). So Im waiting 😁

@im-coder-lg
Copy link
Contributor

Wait I think it's 4.0.0, asked @jsjoeio two days ago and he said that it's straight to 4.0.0.

@im-coder-lg
Copy link
Contributor

#4490 (reply in thread)

This was the reply, so there's no 3.12.1 or 3.12.2.

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 15, 2021

Yes! Jupyter kernel should be working in the next release (it was 3.12.1 but it will be 4.0.0) as @im-coder-lg mentioned!

@simeneide
Copy link
Author

simeneide commented Jan 6, 2022

Hi,
UPDATE: I deleted all my old config files and then it worked, so probably something there making some issues. So false alarm :)


I downloaded 4.0.1 now and installed python+jupyter extensions. When starting a jupyter notebook I still get the Command 'Jupyter: Create New Blank Notebook' resulted in an error (command 'jupyter.createnewnotebook' not found) error. The errors in the developer console looks equivalent to the one reported at the start of this issue.

Update: This was done on an ubuntu-machine, not macOS (as brew doesnt install 4.0.1 yet)

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 7, 2022

Hmm @simeneide I just tested this the other day here and it worked as expected. Can you take a look at that comment?

@simeneide
Copy link
Author

yes sorry @jsjoeio , in my update I note that when I deleted my old config files it ran smoothing. dont know why, but it runs well now :)

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 7, 2022

@simeneide hooray! Well I'm happy it was easy as that :) Thanks for confirming so quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high-priority This issue needs to be resolved ASAP
Projects
None yet
Development

Successfully merging a pull request may close this issue.