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

not able to start jupyter notebook imported into python using wsl when running as the root user #1124

Closed
Tracked by #1122
matthewchung74 opened this issue Sep 24, 2019 · 17 comments
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel)

Comments

@matthewchung74
Copy link

Environment data

  • VS Code version: 1.38.1
  • Extension version (available under the Extensions sidebar): Python 2019.9.34911
  • OS and version: windows 10.0.17763
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.7.3 conda 4.7.12
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: XXX
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version vscode-python#3977): jedi, but happens both ways

Expected behaviour

Actual behaviour

run cell for this

#%%
import os

gives

Executing code failed : Error: Jupyter server crashed. Unable to connect. Error code from jupyter: 1

Steps to reproduce:

  1. open wsl
  2. launch conda environment
  3. open vscode
  4. create .py file with
#%%
import os
  1. run cell

see error message

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

cwd: /mnt/c/Users/matt/Documents/code/course-v3/nbs/dl-me
##########Linting Output - pylint##########
> ~/anaconda3/bin/python -m jupyter kernelspec list
> ~/anaconda3/bin/python -m jupyter kernelspec list
> ~/anaconda3/bin/python -m jupyter notebook --no-browser --notebook-dir=/tmp/fe814943-4e41-421f-b230-8b5c217dbebe --config=/tmp/fe814943-4e41-421f-b230-8b5c217dbebe/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0
> ~/anaconda3/bin/python -m jupyter kernelspec list
> ~/anaconda3/bin/python -m jupyter kernelspec list
> ~/anaconda3/bin/python -m jupyter notebook --no-browser --notebook-dir=/tmp/ccb8d822-bb60-48d3-9f12-937035982aa7 --config=/tmp/ccb8d822-bb60-48d3-9f12-937035982aa7/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0

console

i wasn't able to find Enable source map support for extension debugging advice?


I'm able to get this working on my mac but would love it on my PC for the GPU.
@rchiodo
Copy link
Contributor

rchiodo commented Sep 24, 2019

This may be a problem with an out of date jupyter.

Can you try this from the same python environment and respond with the results?
python -m jupyter notebook --version

Additionally if you could goto 'Help | Toggle Developer Tools', click on the console tab, right click save as, and upload the log, that would help too.

@rchiodo
Copy link
Contributor

rchiodo commented Sep 24, 2019

This may also be related to our default config we specify for jupyter. See this similar issue here:
https://github.com/microsoft/vscode-python/issues/6762

@matthewchung74
Copy link
Author

here's what i get with the jupyter version running from the vscode terminal

(base) root@DESKTOP-LFEDEL2:/mnt/c/Users/matt/Documents# python -m jupyter notebook --version
6.0.0'

attached is the console log
https://gist.github.com/foobar8675/dc2735443e56e685602e41b5720054af

@matthewchung74
Copy link
Author

I tried toggling use default config for jupyter but that's not making a difference. i went also went ahead and created a ~/.jupyter/jupyter_notebook_config.py with c.NotebookApp.ip = '127.0.0.1' but that doesn't seem to make a difference :(

@rchiodo
Copy link
Contributor

rchiodo commented Sep 25, 2019

That console log doesn't have everything in it. It looks like you only uploaded the errors? Hopefully jupyter output something else that can show us what the problem is.

Error code 1 is EPERM, so perhaps your jupyter is configured to require a password.

@matthewchung74
Copy link
Author

For the password, I took a look in the jupyter_notebook_config.py and see the following line is commented out. #c.NotebookApp.password = '' . Not sure where else to look for password settings. I can launch jupyter from the command line and view in a browser w/o password.

I clicked on the console->messages and updated the gist above. However, looking at it, I didn't see anything useful. :(

In vscode, I went to output -> Python to look at the logs for jupyter and added a gist here. https://gist.github.com/foobar8675/6caf97a4014795c505cb80f67c1a3b45 In looking at it, I'm not sure I see what a problem might be

@rchiodo
Copy link
Contributor

rchiodo commented Sep 25, 2019

That's still not the right console log. That looks like the output from the python tab of the 'output' window.

The console log is what you're showing in your screenshot above, you're just only showing errors. It should be rather large. This is what mine looks like:
-1569429664138.log

@rchiodo
Copy link
Contributor

rchiodo commented Sep 25, 2019

I should also mention that a normal jupyter notebook isn't running the same way as us. We're closer to jupyter lab. We talk to the tornado server that jupyter starts up. That's likely where the problem is. Hopefully Jupyter is outputting something telling us why it's crashing.

@matthewchung74
Copy link
Author

Thanks for clarifying for the logs. I'll regenerate that log file tonight when I'm back on that computer. I also didn't know jupyter ran Tornado under the hood. I've been looking at Starlette but will also look at Tornado.

@matthewchung74
Copy link
Author

i just generated a new log which is here. https://gist.github.com/foobar8675/87bd0d2f2047840ed500af0f3fbf6e9f and noticed one line that looked suspicious.

console.ts:137 [Extension Host] Info Python Extension: 2019-09-25 21:37:31: [C 22:37:31.404 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.

so i ran this with the following output

(base) root@DESKTOP-LFEDEL2:/mnt/c/Users/matt/Documents/code/course-v3/nbs/dl-me# ~/anaconda3/bin/python -m jupyter notebook --no-browser --notebook-dir=/tmp/f0c16a0f-1292-46e5-af9a-b33f32c9b3ee --NotebookApp.iopub_data_rate_limit=10000000000.0
[I 22:43:34.730 NotebookApp] JupyterLab extension loaded from /root/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 22:43:34.731 NotebookApp] JupyterLab application directory is /root/anaconda3/share/jupyter/lab
[C 22:43:34.733 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.

then ran this

(base) root@DESKTOP-LFEDEL2:/mnt/c/Users/matt/Documents/code/course-v3/nbs/dl-me# ~/anaconda3/bin/python -m jupyter notebook --no-browser --notebook-dir=/tmp/f0c16a0f-1292-46e5-af9a-b33f32c9b3ee --NotebookApp.iopub_data_rate_limit=10000000000.0 --allow-root
[I 22:44:30.968 NotebookApp] JupyterLab extension loaded from /root/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 22:44:30.969 NotebookApp] JupyterLab application directory is /root/anaconda3/share/jupyter/lab
[I 22:44:30.970 NotebookApp] Serving notebooks from local directory: /tmp/f0c16a0f-1292-46e5-af9a-b33f32c9b3ee
[I 22:44:30.970 NotebookApp] The Jupyter Notebook is running at:
[I 22:44:30.970 NotebookApp] http://127.0.0.1:8888/?token=2bde53de571d92fb6fc75075c91e7eb5c77713cf27dde706
[I 22:44:30.971 NotebookApp]  or http://127.0.0.1:8888/?token=2bde53de571d92fb6fc75075c91e7eb5c77713cf27dde706
[I 22:44:30.971 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 22:44:30.976 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///root/.local/share/jupyter/runtime/nbserver-1005-open.html
    Or copy and paste one of these URLs:
        http://127.0.0.1:8888/?token=2bde53de571d92fb6fc75075c91e7eb5c77713cf27dde706
     or http://127.0.0.1:8888/?token=2bde53de571d92fb6fc75075c91e7eb5c77713cf27dde706

which seemed ok. so i tweaked my jupyter_notebook_config.py to the following https://gist.github.com/foobar8675/583a49ddb027cd9e4e7ee0d347111eaf and in vscode, turned off

snip

and it seemed to work!

Did I miss something in the instructions about not using a root user?

@rchiodo
Copy link
Contributor

rchiodo commented Sep 26, 2019

No we don't specify that anywhere. I should add that to our list of stuff to check.

We've hit this before with docker containers, so we auto detect docker and pass the --allow-root flag.

Glad you got it working. I'm going to change this bug to detect root access and/or update our docs to say don't run as root.

@rchiodo rchiodo changed the title not able to start jupyter notebook imported into python using wsl not able to start jupyter notebook imported into python using wsl when running as the root user Sep 26, 2019
@matthewchung74
Copy link
Author

Got it and thank you for all your help @rchiodo . I'm not sure if this issue should stay open or closed?

@rchiodo
Copy link
Contributor

rchiodo commented Sep 26, 2019

I'd like to leave it open so we can check for root access and warn the user. Thanks.

@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 13, 2020
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug temp-address-multiple-venv-conda labels Nov 13, 2020
@Qiuzhuang
Copy link

Qiuzhuang commented Feb 27, 2021

i just generated a new log which is here. https://gist.github.com/foobar8675/87bd0d2f2047840ed500af0f3fbf6e9f and noticed one line that looked suspicious.

console.ts:137 [Extension Host] Info Python Extension: 2019-09-25 21:37:31: [C 22:37:31.404 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.

so i ran this with the following output

(base) root@DESKTOP-LFEDEL2:/mnt/c/Users/matt/Documents/code/course-v3/nbs/dl-me# ~/anaconda3/bin/python -m jupyter notebook --no-browser --notebook-dir=/tmp/f0c16a0f-1292-46e5-af9a-b33f32c9b3ee --NotebookApp.iopub_data_rate_limit=10000000000.0
[I 22:43:34.730 NotebookApp] JupyterLab extension loaded from /root/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 22:43:34.731 NotebookApp] JupyterLab application directory is /root/anaconda3/share/jupyter/lab
[C 22:43:34.733 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.

then ran this

(base) root@DESKTOP-LFEDEL2:/mnt/c/Users/matt/Documents/code/course-v3/nbs/dl-me# ~/anaconda3/bin/python -m jupyter notebook --no-browser --notebook-dir=/tmp/f0c16a0f-1292-46e5-af9a-b33f32c9b3ee --NotebookApp.iopub_data_rate_limit=10000000000.0 --allow-root
[I 22:44:30.968 NotebookApp] JupyterLab extension loaded from /root/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 22:44:30.969 NotebookApp] JupyterLab application directory is /root/anaconda3/share/jupyter/lab
[I 22:44:30.970 NotebookApp] Serving notebooks from local directory: /tmp/f0c16a0f-1292-46e5-af9a-b33f32c9b3ee
[I 22:44:30.970 NotebookApp] The Jupyter Notebook is running at:
[I 22:44:30.970 NotebookApp] http://127.0.0.1:8888/?token=2bde53de571d92fb6fc75075c91e7eb5c77713cf27dde706
[I 22:44:30.971 NotebookApp]  or http://127.0.0.1:8888/?token=2bde53de571d92fb6fc75075c91e7eb5c77713cf27dde706
[I 22:44:30.971 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 22:44:30.976 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///root/.local/share/jupyter/runtime/nbserver-1005-open.html
    Or copy and paste one of these URLs:
        http://127.0.0.1:8888/?token=2bde53de571d92fb6fc75075c91e7eb5c77713cf27dde706
     or http://127.0.0.1:8888/?token=2bde53de571d92fb6fc75075c91e7eb5c77713cf27dde706

which seemed ok. so i tweaked my jupyter_notebook_config.py to the following https://gist.github.com/foobar8675/583a49ddb027cd9e4e7ee0d347111eaf and in vscode, turned off

snip

and it seemed to work!

Did I miss something in the instructions about not using a root user?

this fixed issue with root remote connection to start jupyter via vscode - remember to restart vscode after changing 'default config for jupypter'

@greazer greazer added the notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) label Apr 23, 2021
@greazer greazer added this to the July 2021 Release milestone Jun 8, 2021
@greazer greazer modified the milestones: July 2021, August 2021 Jul 30, 2021
@greazer greazer added notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) and removed notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) labels Aug 2, 2021
@greazer greazer modified the milestones: August 2021, old August 2021 Aug 9, 2021
@greazer greazer removed this from the old August 2021 milestone Aug 14, 2021
@DonJayamanne
Copy link
Contributor

Using raw kernels should fix this, i.e. ensure we have zeromq support
Will be fixed with #5206

@DonJayamanne
Copy link
Contributor

@Qiuzhuang sorry for not getting back to you on this. wanted to check if this is still unresolved?

@DonJayamanne DonJayamanne added WSL info-needed Issue requires more information from poster and removed issue_grooming_don labels Oct 19, 2021
@Qiuzhuang
Copy link

Yes, this is working perfectly now. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel)
Projects
None yet
Development

No branches or pull requests

5 participants