7

I am trying to launch jupyter lab in VSCode remote server, capsuled by Docker, but got error saying

Unable to start session for kernel Python 3.8.5 64-bit. Select another kernel to launch with.

I set up Dockerfile and .devcontainer.json in workspace dir. Do I also need docker-compose.yaml file for jupyter lab setting like port forwarding? Or I can handle and replace docker-compose file by .devcontainer.json file?

Dockerfile:

FROM python:3.8
RUN apt-get update --fix-missing && apt-get upgrade -y
# Set Japanese UTF-8 as locale so Japanese can be used
RUN apt-get install -y locales \
    && locale-gen ja_JP.UTF-8

ENV LANG ja_JP.UTF-8
ENV LANGUAGE ja_JP:ja
ENV LC_ALL ja_JP.UTF-8

# RUN apt-get install zsh -y && \
#     chsh -s /usr/bin/zsh

# Install zsh with theme and some plugins
RUN sh -c "$(wget -O- https://raw.githubusercontent.com/deluan/zsh-in-docker/master/zsh-in-docker.sh)" \
    -t mrtazz \
    -p git -p ssh-agent

RUN pip install jupyterlab
RUN jupyter serverextension enable --py jupyterlab

WORKDIR /app

CMD ["bash"]

.devcontainer.json

{
"name": "Python 3.8",
"build": {
    "dockerfile": "Dockerfile",
    "context": ".."

},

    // Uncomment to use docker-compose
    // "dockerComposeFile": "docker-compose.yml",
    // "service": "dev",


    // Set *default* container specific settings.json values on container create.
    "settings": {
        "terminal.integrated.shell.linux": "/bin/bash",
        "python.pythonPath": "/usr/local/bin/python",
        "python.linting.enabled": true,
        "python.linting.pylintEnabled": true,
        "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
        "python.formatting.blackPath": "/usr/local/py-utils/bin/black",
        "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
        "python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
        "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
        "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
        "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
        "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
        "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
    },
    // Add the IDs of extensions you want installed when the container is created.
    "extensions": [
        "ms-python.python",
        "teabyii.ayu",
        "jeff-hykin.better-dockerfile-syntax",
        "coenraads.bracket-pair-colorizer-2",
        "file-icons.file-icons",
        "emilast.logfilehighlighter",
        "zhuangtongfa.material-theme",
        "ibm.output-colorizer",
        "wayou.vscode-todo-highlight",
        "atishay-jain.all-autocomplete",
        "amazonwebservices.aws-toolkit-vscode",
        "hookyqr.beautify",
        "phplasma.csv-to-table",
        "alefragnani.bookmarks",
        "mrmlnc.vscode-duplicate",
        "tombonnike.vscode-status-bar-format-toggle",
        "donjayamanne.githistory",
        "codezombiech.gitignore",
        "eamodio.gitlens",
        "zainchen.json",
        "ritwickdey.liveserver",
        "yzhang.markdown-all-in-one",
        "pkief.markdown-checkbox",
        "shd101wyy.markdown-preview-enhanced",
        "ionutvmi.path-autocomplete",
        "esbenp.prettier-vscode",
        "diogonolasco.pyinit",
        "ms-python.vscode-pylance",
        "njpwerner.autodocstring",
        "kevinrose.vsc-python-indent",
        "mechatroner.rainbow-csv",
        "msrvida.vscode-sanddance",
        "rafamel.subtle-brackets",
        "formulahendry.terminal",
        "tyriar.terminal-tabs",
        "redhat.vscode-yaml"
    ],

    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    "forwardPorts": [8888],

    // Use 'postCreateCommand' to run commands after the container is created.
    // "postCreateCommand": "pip3 install -r requirements.txt",

    // Comment out to connect as root instead.
    // "remoteUser": "myname",

    "shutdownAction": "none"
}
SayZ
  • 101
  • 1
  • 5
  • @S Ka Could you use the Jupyter notebook function in VSCode normally when you are not using "Docker"? (Like this: "Ctrl+ Shift+p", "Python: Create New Blank Jupyter Notebook") – Jill Cheng Sep 04 '20 at 01:33

1 Answers1

0

I believe is an issue with VSCode and not with your Docker container, I got it running by adding a couple extensions to resolve the kernel resolution.

Can you try adding these extensions to your devcontainer.json file?

"ms-toolsai.jupyter",
"ms-toolsai.vscode-jupyter-powertoys"

Also remember a devcontainer is not a regular Docker container remove this

WORKDIR /app
CMD ["bash"]

And replaced them with

ENV DEVCONTAINER=true

Finally this line was giving me errors:

RUN jupyter serverextension enable --py jupyterlab
San Bluecat
  • 169
  • 4