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

Document how to use Python & Jupyter #4333

Closed
AyaanZaveri opened this issue Oct 10, 2021 · 10 comments
Closed

Document how to use Python & Jupyter #4333

AyaanZaveri opened this issue Oct 10, 2021 · 10 comments
Labels
docs Documentation related
Milestone

Comments

@AyaanZaveri
Copy link

  1. First, add these lines to your Dockerfile to install Miniconda/Anaconda:
RUN curl -sfLO https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh \
 && /bin/bash Miniconda3-py39_4.9.2-Linux-x86_64.sh -b -p /root/miniconda \
 && PATH="/root/miniconda/bin:$PATH" \
 && conda install -c anaconda jupyter
  1. Then, install the Python Extension and make sure it comes with the Jupyter Extension or you can add this line to your Dockerfile:
RUN code-server --install-extension ms-python.python
RUN code-server --install-extension ms-toolsai.jupyter
  1. Next, in Code-Server create a file with the extension .ipynb like main.ipynb and set your Python Interpreter as the location of miniconda (~/miniconda/bin/python).
  2. Finally, you can add your python code to the file and it should work perfectly.
    Screen Shot 2021-10-09 at 6 35 56 PM
    Screen Shot 2021-10-09 at 6 36 52 PM

If this doesn't work use the Dockerfile from #3199 (comment)

@AyaanZaveri AyaanZaveri added the docs Documentation related label Oct 10, 2021
@jsjoeio jsjoeio pinned this issue Oct 11, 2021
@jsjoeio jsjoeio changed the title Figured out how to use Jupyter. Document how to use Python & Jupyter Oct 11, 2021
@jsjoeio jsjoeio added this to the On Deck milestone Oct 11, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented Oct 11, 2021

Great work @AyaanZaveri! This is fantastic. Thanks for taking the time to write this up. I've pinned it for now (until we can get around to adding this to the docs). This should be a guide in it of itself.

@0x0L
Copy link

0x0L commented Oct 12, 2021

Hi,

Using this dockerfile

FROM debian:buster-slim

ENV SHELL /bin/bash

# Install system dependencies
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    curl \
    wget \
    git \
    screen \
    unzip \
    vim \
    procps \
 && apt-get clean

ENV PATH=/opt/conda/bin:$PATH

RUN wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
 && /bin/bash Miniconda3-latest-Linux-x86_64.sh -f -b -p /opt/conda \
 && rm Miniconda3-latest-Linux-x86_64.sh \
 && conda install --quiet --yes jupyter

RUN curl -fsSL https://code-server.dev/install.sh | sh

RUN code-server --install-extension ms-python.python
RUN code-server --install-extension ms-toolsai.jupyter

WORKDIR /tmp
CMD code-server --bind-addr 0.0.0.0:8080 --auth=none /tmp

# docker build -t jupyter .
# docker run -p 8080:8080 -it --rm jupyter

I'm unable to create a new blank notebook or run a pre-existing notebook. Here's the error trace in the output logs

[2021-10-12 19:46:45.568] [exthost] [error] Activating extension ms-toolsai.jupyter failed due to an error:
[2021-10-12 19:46:45.568] [exthost] [error] Error: Cannot find module '/root/.local/share/code-server/extensions/ms-toolsai.jupyter-2021.8.12/out/client/extension'
Require stack:
- /usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/loader.js
- /usr/lib/code-server/vendor/modules/code-oss-dev/out/bootstrap-amd.js
- /usr/lib/code-server/vendor/modules/code-oss-dev/out/bootstrap-fork.js
	at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
	at Function.Module._load (internal/modules/cjs/loader.js:745:27)

There's an out/client_renderer/ dir but no out/client/

@AyaanZaveri
Copy link
Author

You can try removing the lines:

RUN code-server --install-extension ms-python.python
RUN code-server --install-extension ms-toolsai.jupyter

and install the Python extension manually (It should be bundled with the Jupyter Extension).

@0x0L
Copy link

0x0L commented Oct 12, 2021

Same result

@AyaanZaveri
Copy link
Author

Can you try to use the exact same Dockerfile?

FROM debian:buster-slim

ENV SHELL /bin/bash
  
# Install system dependencies
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    curl \
    wget \
    git \
    screen \
    unzip \
    vim \
    procps \
 && apt-get clean

# Install miniconda
RUN curl -sfLO https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh \
 && /bin/bash Miniconda3-py39_4.9.2-Linux-x86_64.sh -b -p /root/miniconda \
 && PATH="/root/miniconda/bin:$PATH" \
 && conda install -c anaconda jupyter

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

WORKDIR /app
CMD ~/.local/bin/code-server --bind-addr 0.0.0.0:8080 /app

# docker build -t jupyter .
# docker run -v $(pwd):/app -p 8080:8080 -p ... -it -d jupyter
# docker exec -it <dontainer_id> cat /root/.config/code-server/config.yaml

Does that work?

@0x0L
Copy link

0x0L commented Oct 12, 2021

Yes that does work but it's vscode 1.54 with the old notebooks

@edvincent
Copy link
Contributor

@jsjoeio I finally got around to read your (great!) worklog in #3874 and I'm not sure we fixed the original root-cause, which is still what @0x0L is seeing here?

As in, I think the problem you fixed with #4231 was a change on the API itself for the future versions of vscode (as it was the insider's version).

The current root-cause still is that the ms-toolsai.jupyter scraped and exposed in the default gallery of code-server (https://storage.googleapis.com/vscode-extension-assets/vscode-extensions/vscode/ms-toolsai/jupyter/2021.8.12/Microsoft.VisualStudio.Services.VSIXPackage) is missing the extension itself, as the out/ folder is missing some nested folder:

  • out/client_renderer/ exists.
  • out/client/ is missing, which is actually where some of the code is - and the error that we are seeing?

Unless moving to Open VSX (#4319) will indeed come with 3.12.1 (and even depending on the release date), there likely still is some work to do to ensure the extension vended in code-server's current gallery is complete...

I would recommend to re-upload a working extension to code-server's VSX gallery, either by taking it from Open VSX or GitHub, or building it locally? I'm happy to provide a version that I'd build myself so you can upload it?

@0x0L As per the matrix I created here the only working version of ms-toolsai.jupyter are the ones downloaded from Open VSX or GitHub build artifacts. The ones vended by the current gallery won't work.

If you don't want to completely switch to Open VSX, I reckon the following should work in a Dockerfile - just to install the extensions?

RUN SERVICE_URL="https://open-vsx.org/vscode/gallery" ITEM_URL="https://open-vsx.org/vscode/item" code-server --install-extension ms-python.python
RUN SERVICE_URL="https://open-vsx.org/vscode/gallery" ITEM_URL="https://open-vsx.org/vscode/item" code-server --install-extension ms-toolsai.jupyter

@0x0L
Copy link

0x0L commented Oct 17, 2021

Thanks @edvincent for your matrix. I used the extensions from the official market place as a temporary fix

@jsjoeio
Copy link
Contributor

jsjoeio commented Oct 28, 2021

Unless moving to Open VSX (#4319) will indeed come with 3.12.1 (and even depending on the release date), there likely still is some work to do to ensure the extension vended in code-server's current gallery is complete...

I'm hopeful we can make it happen with 3.12.1

I would recommend to re-upload a working extension to code-server's VSX gallery, either by taking it from Open VSX or GitHub, or building it locally? I'm happy to provide a version that I'd build myself so you can upload it?

That would save a lot of time and would be super appreciated 🙏

@stale
Copy link

stale bot commented Apr 27, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days.

@stale stale bot added the stale label Apr 27, 2022
@stale stale bot closed this as completed May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related
Projects
None yet
Development

No branches or pull requests

4 participants