Jupyterlab defaulst to Python3 Kernel

735 views
Skip to first unread message

Ek Esawi

unread,
Jul 25, 2022, 5:22:20 PM7/25/22
to Project Jupyter
Hi all--

I installed Jupyterlab with python3 and kernels installed. I added Julia kernel. Now, every time i open a  new notebook, the file automatically given ipynb extension. When i change the kernel to R, the code does not run and the kernel on top right changes to no kernel and defaults back to Python3.

If i chose Julia kernel, i get this error "error starting kernel, unhandled error"

Any input is highly appreciated.

EK

Kevin Bates

unread,
Jul 25, 2022, 8:06:00 PM7/25/22
to Project Jupyter
Hello EK.

The ".ipynb" extension is not meant to indicate the type of kernel to which the notebook file is associated, it's purely an indicator that this is a Jupyter notebook and is more a function of the project having been originally named IPython.  Had the project been named Jupyter from the start, I imagine the extension would have been ".jnb".

I suspect your R and Julia kernels are not correctly configured since it appears the server knows about them (as they are selectable) but is encountering an error during their startup.  I recommend looking at your server's console (where the Lab instance was started) since there should be some information specific to the failed start attempts.  You probably have some additional dependencies missing.  You will likely need to look at the `argv` stanza of the `kernel.json` file associated with your R and/or Julia kernels since that is the command that is issued to start each kernel.

Lastly, if you would like to change your "default" kernel, you can configure 'MappingKernelManager.default_kernel_name=julia'.  This can be done within a configuration file via 'c.MappingKernelManager.default_kernel_name=julia' or the command line via '--MappingKernelManager.default_kernel_name=julia'.  Note that I'm not familiar with the Julia kernel or its default naming but am assuming its configuration resides in the directory named 'julia' - which is the target of the 'default_kernel_name' attribute I reference and where its aforementioned `kernel.json` file will reside.

Note that the directories for where the `kernel.json` files reside can be found using `jupyter kernelspec list` and (for completeness) the left-hand values of that output is the string that should be referenced in the 'default_kernel_name' configuration option.

Best regards,
Kevin.

Ek Esawi

unread,
Jul 25, 2022, 9:04:12 PM7/25/22
to jup...@googlegroups.com

Kevin,

 

Thank you so much for your help. The name issue makes sense now. The issue with the R kernel is that it doesn’t  generate any errors. It just simply will not run the code and suddenly, instead of the active kernel is R, changes to no kernel.

 

Julia, on the other hand, generates messages but I don’t understand them and don’t want to post the whole page of messages because it may not be appropriate to do so. Here are the listed kernels

Available kernels:

  ir           C:\Users\eesawi\AppData\Roaming\jupyter\kernels\ir

  julia-1.7    C:\Users\eesawi\AppData\Roaming\jupyter\kernels\julia-1.7

  python3      c:\users\eesawi\appdata\local\programs\python\python39\share\jupyter\kernels\python3

I looked at each kernel json file, but I don’t know how to change them to run the kernels properly.

Here are the 2 json files

{

  "argv": ["C:/PROGRA~1/R/R-41~1.0/bin/x64/R", "--slave", "-e", "IRkernel::main()", "--args", "{connection_file}"],

  "display_name": "R",

  "language": "R"

}

 

{

  "display_name": "Julia 1.7.3",

  "interrupt_mode": "message",

  "argv": [

    "C:\\Users\\eesawi\\Downloads\\julia-1.7.3-win32\\julia-1.7.3\\bin\\julia.exe",

    "-i",

    "--color=yes",

    "--project=@.",

    "C:\\Users\\eesawi\\.julia\\packages\\IJulia\\AQu2H\\src\\kernel.jl",

    "{connection_file}"

  ],

  "env": {},

  "language": "julia"

}


EK


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/9be078cd-147d-49f7-97d1-94ccdff443b1n%40googlegroups.com.

Ek Esawi

unread,
Jul 26, 2022, 1:18:13 PM7/26/22
to Project Jupyter
Hi Again,

I reinstalled R; now both R and Julia kernels give the same error "error installing kernel unhandled  error, unhandled error"; details are below

[I 2022-07-26 09:21:24.106 ServerApp] Creating new notebook in /Documents/EK EsawiPD/Scripts

[E 2022-07-26 09:21:25.228 ServerApp] Failed to run command:

    ['C:/PROGRA~1/R/R-41~1.0/bin/x64/R', '--slave', '-e', 'IRkernel::main()', '--args', 'C:\\Users\\eesawi\\AppData\\Roaming\\jupyter\\runtime\\kernel-04406fc5-9a32-453f-bf4b-f5dd9ed82505.json']

        PATH='C:\\Program Files (x86)\\Razer Chroma SDK\\bin;C:\\Program Files\\Razer Chroma SDK\\bin;C:\\Program Files (x86)\\Razer\\ChromaBroadcast\\bin;C:\\Program Files\\Razer\\ChromaBroadcast\\bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Users\\eesawi\\AppData\\Local\\Programs\\Python\\Python35;C:\\Users\\eesawi\\AppData\\Local\\Programs\\Python\\Python35\\Scripts;C:\\Program Files\\Git\\cmd;C:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\eesawi\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\eesawi\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\eesawi\\AppData\\Local\\Programs\\Python\\Python39\\Scripts;C:\\Users\\eesawi\\AppData\\Local\\atom\\bin;%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;'

        with kwargs:

    {'stdin': -1, 'stdout': None, 'stderr': None, 'cwd': 'C:\\Users\\eesawi\\Documents\\EK EsawiPD\\Scripts', 'close_fds': False}

 

[E 2022-07-26 09:21:25.228 ServerApp] Uncaught exception POST /api/sessions?1658852485196 (127.0.0.1)

    HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions?1658852485196', version='HTTP/1.1', remote_ip='127.0.0.1')

    Traceback (most recent call last):

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\tornado\web.py", line 1704, in _execute

        result = await result

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_server\services\sessions\handlers.py", line 67, in post

        model = await sm.create_session(

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_server\services\sessions\sessionmanager.py", line 91, in create_session

        kernel_id = await self.start_kernel_for_session(session_id, path, name, type, kernel_name)

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_server\services\sessions\sessionmanager.py", line 99, in start_kernel_for_session

        kernel_id = await self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_server\services\kernels\kernelmanager.py", line 187, in start_kernel

        kernel_id = await ensure_async(self.pinned_superclass.start_kernel(self, **kwargs))

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_server\utils.py", line 172, in ensure_async

        result = await obj

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_client\multikernelmanager.py", line 483, in start_kernel

        await fut

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_client\multikernelmanager.py", line 460, in _add_kernel_when_ready

        await kernel_awaitable

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_client\manager.py", line 661, in start_kernel

        self.kernel = await self._launch_kernel(kernel_cmd, **kw)

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_client\manager.py", line 642, in _launch_kernel

        res = launch_kernel(kernel_cmd, **kw)

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\site-packages\jupyter_client\launcher.py", line 132, in launch_kernel

        proc = Popen(cmd, **kwargs)

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\subprocess.py", line 951, in __init__

        self._execute_child(args, executable, preexec_fn, close_fds,

      File "c:\users\eesawi\appdata\local\programs\python\python39\lib\subprocess.py", line 1420, in _execute_child

        hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

    FileNotFoundError: [WinError 2] The system cannot find the file specified

[W 2022-07-26 09:21:25.468 ServerApp] Unhandled error

[E 2022-07-26 09:21:25.471 ServerApp] {

      "Host": "localhost:8888",

      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0",

      "Accept": "*/*",

      "Accept-Language": "en-US,en;q=0.5",

      "Accept-Encoding": "gzip, deflate",

      "Referer": "http://localhost:8888/lab/tree/Documents/EK%20EsawiPD/Scripts/Untitled2.ipynb",

      "Content-Type": "text/plain;charset=UTF-8",

      "Authorization": "token c2471bb8fc507afe67c6e214fea4d923bdf1ab74b4baea3d",

      "X-Xsrftoken": "2|6bc60900|7dac534b086993b020c27c66807bdf22|1658266876",

      "Origin": "http://localhost:8888",

      "Content-Length": "142",

      "Connection": "keep-alive",

      "Cookie": "_xsrf=2|6bc60900|7dac534b086993b020c27c66807bdf22|1658266876; username-localhost-8888=\"2|1:0|10:1658852485|23:username-localhost-8888|44:MzM3NGU2MzM4YzcxNDI4YWE2ZTExYzQ4ZTk4OWRiNzY=|6e9df3938d5b32de3b028e7120e94b3b1ecc08d227f15b2c96c0e1804a6329b0\"",

      "Sec-Fetch-Dest": "empty",

      "Sec-Fetch-Mode": "cors",

      "Sec-Fetch-Site": "same-origin",

      "Pragma": "no-cache",

      "Cache-Control": "no-cache"

    }

[E 2022-07-26 09:21:25.474 ServerApp] 500 POST /api/sessions?1658852485196 (127.0.0.1) 273.75ms referer=http://localhost:8888/lab/tree/Documents/EK%20EsawiPD/Scripts/Untitled2.ipynb

Kevin Bates

unread,
Jul 26, 2022, 4:45:58 PM7/26/22
to Project Jupyter
"FileNotFoundError: [WinError 2] The system cannot find the file specified" is typically due to the program that Jupyter is trying to launch (i.e., the kernel process) not being found.  This is presented by the first entry of the argv list in the corresponding kernel.json file.  I recommend double-checking those paths (and any others in each of the kernel.json files) and ensuring each is accessible from the CMD prompt.  Should any changes be necessary, these are text files that must be loaded as JSON, so any text editor should be fine provided the JSON structure is preserved.  If you happen to mess up the structure, the symptom you'll see is that that particular kernel is no longer available in the kernel selection list.

I can also tell from the stack trace that you're running with an older version of jupyter_client.  This shouldn't be a problem but wanted to point that out in case you do find an issue with the Jupyter packages.  At present, this issue has all the symptoms of configuration related where some file references don't "line up" with what's actually there.  These kinds of issues can tend to be more frustrating in Windows environments where the path separators can vary, drive letters are in play, '~' are used to shorten paths, etc.

It looks like your argv for Julia is a bit cleaner relative to Windows, so I would start with that kernel in your troubleshooting efforts.

Ek Esawi

unread,
Jul 27, 2022, 10:15:39 PM7/27/22
to Project Jupyter
Kevin,

Thanks again. I managed to get the R kernel to work properly. To fix the R kernel issue, i removed it and installed it from R official website where there are very easy and clear instructions on how to do that. https://irkernel.github.io/installation/

I deleted the old Julia kernel, IJulia,, that appears on the console but did not work, and reinstalled it from Julia. Now, the kernel does not appear on jupyter console, and i could not figure out how to make jupyter recognizes it. There are reported issues with Julia kernel on jupyter; one of them is that julia kernel installs conda with it;  i did not use conda.

Thanks again, EK

Kevin Bates

unread,
Jul 28, 2022, 2:57:44 PM7/28/22
to Project Jupyter
Glad to hear you're moving forward with R.  Regarding Julia, did you run the Pkg.add("IJulia") from the Julia command prompt after its reinstallation?  This is what creates the kernel specification file so that it's usable from Jupyter.  After doing so, run jupyter kernelspec list to ensure the Julia kernel shows as available.  My (newly installed) Julia kernel shows up as julia-1.7 in this output with a location of /Users/kbates/Library/Jupyter/kernels/julia-1.7 (on macOS and tantamount to the logged-in user's configuration area).  The other nice thing about this command is that, if there were syntax issues with the kernel.json file, they would be displayed (whereas those same issues could get lost in the data produced starting Lab).  What this command does not do that running Lab does is actually invoke the program (which exercises the paths in the kernel.json file) - so if you have problems starting the kernel, you should confirm your paths are correct in the kernel.json file, etc.

Ek Esawi

unread,
Jul 28, 2022, 3:51:46 PM7/28/22
to Project Jupyter
Kevin,

Again thanks a million. It's nice to keep hearing encouraging and helpful replies. I successfully installed everything and all works as it should. For anyone who might run in to such an issue, where either R or Julia and i suspect any other kernel, to make sure you have the latest version of all software installed (Jupyter, Julia, Python, R, etc). Then add the kernels from  the official software website.
 
What caused my problems is that i did not have the latest of Jupyterlab. Once I uninstalled and reinstalled it then adding the kernels did not take more than 10 minutes. I could write down the steps, but i suspect these things change so fast that detailed instructions may not work for others.

EK
Reply all
Reply to author
Forward
0 new messages