Jupyterlab() only works after I run Pkg.build("IJulia") every time

Hi, all of a sudden I am only able to make jupyterlab work properly by running the following before the jupyterlab() call:

using Pkg
Pkg.build("IJulia")

If I don’t do so, jupyterlab open on the browser and gives me a “failed to connect” message. Below is what I see:

julia> using IJulia

julia> jupyterlab()
[ Info: running setenv(`'C:\Users\Gabriel\.julia\conda\3\Scripts\jupyter.exe' lab`,["PATH=C:\\Users\\Gabriel\\.julia\\conda\\3\\Library\\bin;C:\\Users\\Gabriel\\.julia\\conda\\3\\Scripts;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Users\\Gabriel\\AppData\\Local\\Microsoft\\WindowsApps;;C:\\Users\\Gabriel\\AppData\\Local\\Programs\\Julia-1.7.2\\bin", "USERDOMAIN_ROAMINGPROFILE=DESKTOP-FTPN55F", "HOMEPATH=\\Users\\Gabriel", "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC", "SESSIONNAME=Console", "SYSTEMROOT=C:\\Windows", "APPDATA=C:\\Users\\Gabriel\\AppData\\Roaming", "PSMODULEPATH=C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules", "COMMONPROGRAMW6432=C:\\Program Files\\Common Files", "PROGRAMDATA=C:\\ProgramData", "PUBLIC=C:\\Users\\Public", "USERDOMAIN=DESKTOP-FTPN55F", "OS=Windows_NT", "PROCESSOR_REVISION=9702", "TMP=C:\\Users\\Gabriel\\AppData\\Local\\Temp", "COMSPEC=C:\\Windows\\system32\\cmd.exe", "ALLUSERSPROFILE=C:\\ProgramData", "COMPUTERNAME=DESKTOP-FTPN55F", "USERNAME=Gabriel", "CONDARC=C:\\Users\\Gabriel\\.julia\\conda\\3\\condarc-julia.yml", "USERPROFILE=C:\\Users\\Gabriel", "PROCESSOR_LEVEL=6", "PROGRAMW6432=C:\\Program Files", "TEMP=C:\\Users\\Gabriel\\AppData\\Local\\Temp", "HOMEDRIVE=C:", "PYTHONIOENCODING=UTF-8", "WINDIR=C:\\Windows", "ZES_ENABLE_SYSMAN=1", "LOCALAPPDATA=C:\\Users\\Gabriel\\AppData\\Local", "PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 151 Stepping 2, GenuineIntel", "NUMBER_OF_PROCESSORS=24", "=::=::\\", "COMMONPROGRAMFILES(X86)=C:\\Program Files (x86)\\Common Files", "VBOX_MSI_INSTALL_PATH=C:\\Program Files\\Oracle\\VirtualBox\\", "COMMONPROGRAMFILES=C:\\Program Files\\Common Files", "ONEDRIVE=C:\\Users\\Gabriel\\OneDrive", "PROGRAMFILES(X86)=C:\\Program Files (x86)", "OPENBLAS_NUM_THREADS=8", "PROGRAMFILES=C:\\Program Files", "LOGONSERVER=\\\\DESKTOP-FTPN55F", "DRIVERDATA=C:\\Windows\\System32\\Drivers\\DriverData", "CONDA_PREFIX=C:\\Users\\Gabriel\\.julia\\conda\\3", "FPS_BROWSER_USER_PROFILE_STRING=Default", "SYSTEMDRIVE=C:", "FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer", "PROCESSOR_ARCHITECTURE=AMD64", "OPENBLAS_MAIN_FREE=1"])
Process(setenv(`'C:\Users\Gabriel\.julia\conda\3\Scripts\jupyter.exe' lab`,["PATH=C:\\Users\\Gabriel\\.julia\\conda\\3\\Library\\bin;C:\\Users\\Gabriel\\.julia\\conda\\3\\Scripts;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Users\\Gabriel\\AppData\\Local\\Microsoft\\WindowsApps;;C:\\Users\\Gabriel\\AppData\\Local\\Programs\\Julia-1.7.2\\bin", "USERDOMAIN_ROAMINGPROFILE=DESKTOP-FTPN55F", "HOMEPATH=\\Users\\Gabriel", "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC", "SESSIONNAME=Console", "SYSTEMROOT=C:\\Windows", "APPDATA=C:\\Users\\Gabriel\\AppData\\Roaming", "PSMODULEPATH=C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules", "COMMONPROGRAMW6432=C:\\Program Files\\Common Files", "PROGRAMDATA=C:\\ProgramData"  …  "OPENBLAS_NUM_THREADS=8", "PROGRAMFILES=C:\\Program Files", "LOGONSERVER=\\\\DESKTOP-FTPN55F", "DRIVERDATA=C:\\Windows\\System32\\Drivers\\DriverData", "CONDA_PREFIX=C:\\Users\\Gabriel\\.julia\\conda\\3", "FPS_BROWSER_USER_PROFILE_STRING=Default", "SYSTEMDRIVE=C:", "FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer", "PROCESSOR_ARCHITECTURE=AMD64", "OPENBLAS_MAIN_FREE=1"]; dir="C:\\Users\\Gabriel"), ProcessExited(1))

julia>

As you can see, the prompt returns to julia> and on the browser I see:

Capture

If I click on “Dismiss” and try to connect manually by selecting a Kernel on the Jupyterlab page (right upper corner), I get the following:

Capture

I feel that there’s something wrong with this behavior. I don’t think I need to build IJulia every time to make it work. Interestingly, this behavior is not present when opening a simple notebook. When opening notebook() the notebook properly connects with the Kernel right off the bat.

I could not find any similar issues online besides the remedy solution of building IJulia.

If anyone is able to help me figure out what might be going on, I would be very thankful.

Thank you,

Gabriel

Does the same problem happen if you run jupyter lab from the command line (outside of Julia)?

I did open the cmd in windows and typed jupyter notebook and got a message saying that this is not recognized as an internal or external command. I am not experienced with the command line to ensure what I am doing is correct. I noticed also that after the server cannot connect, going back to the REPL and entering jupyterlab() does make jupyter lab work, but this is weird because the first call to open always fails.
Thanks for helping, let me know if there’s something else I can try.

Building IJulia should only be necessary if the location of the julia.exe executable changes.

Is it possible that you are running Julia from some kind of temporary filesystem that changes each time? What is Sys.BINDIR (the location of julia.exe)?

I have figured out what the problem was. Thank you for all the replies. I have a Virtual Machine running Linux Mint and had a kernel running there in Jupyterlab as well (even though the VM was powered off, which is weird). Once shutting down those Kernels, Jupyterlab behaves normally in Windows. This is a very specific issue, but other people might run into the same thing in the future.