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

ADS 1.50 fails to load python kernels for notebooks #26087

Open
Sunspark opened this issue Nov 29, 2024 · 2 comments
Open

ADS 1.50 fails to load python kernels for notebooks #26087

Sunspark opened this issue Nov 29, 2024 · 2 comments

Comments

@Sunspark
Copy link

Type: Bug

ADS 1.50 fails to load kernels

TL;DR:
Currently the most stable fix I have found is:

Load ADS, try and start a notebook. 

This will fail and try and do an install of the ‘correct’ versions of python packages. 

Let the install happen. 

Close all notebooks. 

Open a console and run: 
  "C:\Users\<user>\azuredatastudio-python\python.exe" -m pip install --user "notebook==6.5.5" "ipykernel==5.5.5" 

Open an editor and change line 1411 in $(Python)\Python38\site-packages\notebook\notebookapp.py from 
 'jupyter_server.contents.services.managers.ContentsManager' 
 to 
 'jupyter_server.services.contents.manager.ContentsManager' 

Re open a notebook, and the notebooks should connect to the python kernel / run notebook server fine – until you restart ADS. 

Things I have tried (the long version) :

Using Azure Data Studio 1.50

When opening a notebook, the program attempts to switch kernels to the python 3 kernel, and detects that the requirements are not configured, launching the python configuration window of ADS
Clicking ‘Install’ follows through the install process for the ‘Required Version’ of the listed dependencies.
However – this causes a cascade of bug-like occurrences.
The install sequence completes with ADS trying to lauch the Notebook server, which fails with the following error:
[Start Error message]

Could not start session: Notebook process exited prematurely with error code: 1. StdErr Output: Traceback (most recent call last):

File "c:\Users\B'Skai\AppData\Local\Programs\Azure Data Studio\resources\app\extensions\notebook\resources\pythonScripts\startNotebook.py", line 1, in

import notebook.notebookapp 

ModuleNotFoundError: No module named 'notebook.notebookapp'

[End Error message]

This was a known bug in previous versions of ADS, characterised and community solved here: #23945
This page suggests the ‘fix’ of downgrading the notebook version to sub version 7. Both versions 6.0.3 and 6.5.5 are mentioned.
notebook 6.5.5 installs correctly (downgrading 7.2.2), but attempting to start the notebook server fails with the followning error:

[Start Error message]

Could not start session: Notebook process exited prematurely with error code: 1. StdErr Output: Traceback (most recent call last):

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\notebook\traittypes.py", line 235, in _resolve_classes

klass = self._resolve_string(klass) 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 2015, in _resolve_string

return import_item(string) 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\traitlets\utils\importstring.py", line 33, in import_item

module = __import__(package, fromlist=[obj]) 

ModuleNotFoundError: No module named 'jupyter_server.contents'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "c:\Users\B'Skai\AppData\Local\Programs\Azure Data Studio\resources\app\extensions\notebook\resources\pythonScripts\startNotebook.py", line 2, in

notebook.notebookapp.main() 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\jupyter_core\application.py", line 283, in launch_instance

super().launch_instance(argv=argv, **kwargs) 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\traitlets\config\application.py", line 1073, in launch_instance

app = cls.instance(**kwargs) 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\traitlets\config\configurable.py", line 583, in instance

inst = cls(*args, **kwargs) 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 1292, in new

inst.setup_instance(*args, **kwargs) 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 1335, in setup_instance

super(HasTraits, self).setup_instance(*args, **kwargs) 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\traitlets\traitlets.py", line 1311, in setup_instance

init(self) 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\notebook\traittypes.py", line 226, in instance_init

self._resolve_classes() 

File "C:\Users\B'Skai\AppData\Roaming\Python\Python38\site-packages\notebook\traittypes.py", line 238, in _resolve_classes

warn(f"{klass} is not importable. Is it installed?", ImportWarning) 

TypeError: warn() missing 1 required keyword-only argument: 'stacklevel'

[End Error Message]

This error is characterised, and community solved here: #24436

$(Python) = C:\users//appdata/roaming/python

Changing line 1411 in $(Python)\Python38\site-packages\notebook\notebookapp.py from

'jupyter_server.contents.services.managers.ContentsManager'

to

'jupyter_server.services.contents.manager.ContentsManager'

After this change, when attempting to start the notebook server, the notebook server starts correctly,
However, the python install window re-occurs.
This causes ADS to attempt to install the required versions, which fails.

At this point, explicitly installing notebook 6.5.5 and ipykernel 5.5.5
succeeds at starting the notebook server, and switching kernels to python

However, re-starting ADS causes the same issues over again.

=====================================================
Trying something different - attempting to 'correct' the 'most current' versions.
+++++
Starting from the same point as before, ADS detects 'incorrect' versions, and attempts install.
Having done an install to notebook 7.2.2 / ipykernel 6.29.5

One of the other fixes suggested at #23945 is to alter this file: https://github.com/microsoft/azuredatastudio/blob/main/extensions/notebook/resources/pythonScripts/startNotebook.py

C:\Users<user>\AppData\Local\Programs\Azure Data Studio\resources\app\extensions\notebook\resources\pythonScripts\startNotebook.py

Change line 1 to ‘import notebook.app’
Change line 2 to ‘notebook.app.main()’

Fails to start notebook server with following error:
[Start Error message]

Could not start session: Notebook process exited prematurely with error code: 2. StdErr Output: usage: startNotebook.py [-h] [--debug] [--show-config] [--show-config-json]

                    [--generate-config] [-y] [--allow-root] [--no-browser] 

                    [--autoreload] [--script] [--no-script] 

                    [--expose-app-in-browser] [--custom-css] 

                    [--log-level ServerApp.log_level] 

                    [--config ServerApp.config_file] [--ip ServerApp.ip] 

                    [--port ServerApp.port] 

                    [--port-retries ServerApp.port_retries] 

                    [--sock ServerApp.sock] 

                    [--sock-mode ServerApp.sock_mode] 

                    [--transport KernelManager.transport] 

                    [--keyfile ServerApp.keyfile] 

                    [--certfile ServerApp.certfile] 

                    [--client-ca ServerApp.client_ca] 

                    [--notebook-dir ServerApp.root_dir] 

                    [--preferred-dir ServerApp.preferred_dir] 

                    [--browser ServerApp.browser] 

                    [--pylab ServerApp.pylab] 

                    [--gateway-url GatewayClient.url] 

                    [extra_args [extra_args ...]] 

startNotebook.py: error: unrecognized arguments: --no-mathjax

[End Error message]

Running the ‘start notebook server’ command from the console works fine if you manuallly remove the –no-mathjax argument, but I can’t find a file that has this string in AppData or Program Files/AzureDataStudio.

Modifying the file C:\Users<user>\AppData\Local\Programs\Azure Data Studio\resources\app\extensions\notebook\resources\pythonScripts\startNotebook.py

To add these two lines at 2 and 3:
import sys
sys.argv.remove("--no-mathjax")

(Note these lines will produce an error in the logs if the script is called without the –no-mathajax argument)

Causes the notebook server to attempt to run, but hits the version number check, and ADS attempts to re-install the 'correct' versions

Cancel installation, specifically install ipykernel 5.5.5 from the console
Starts the notebook server fine:
But execution fails with the following error:
[Start Error message]

Could not start session: fetch failed

[End Error message]

Azure Data Studio version: azuredatastudio 1.50.0 (49c73a8, 2024-11-17T22:41:05.327Z)
OS version: Windows_NT x64 10.0.19045
Restricted Mode: No
Preview Features: Enabled
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz (4 x 2496)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.66GB (6.68GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none
@Sunspark
Copy link
Author

It should be noted that this "same bug" has been happening in previous versions of ADS. I executed the same fix of downgrading the notebook install sometime in August 24 when v1.49 came out. However, the fix was 'stable' - it lasted until the release of v1.50.
The new development is that v1.50 appears to be doing the python module version check on launch every time, meaning that you have to do the notebook re-install and changes every time - which is really vexing.

@torero619
Copy link

Thank you for this stable workaround @Sunspark , I've tried other solutions but this is the only one that works consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants