jupyterlab-desktop icon indicating copy to clipboard operation
jupyterlab-desktop copied to clipboard

JupyterLab on Windows does not properly activate conda environment

Open ukoethe opened this issue 3 years ago • 13 comments

This might be related to #381 and #386.

After installation on Windows, I got the "Server Initialization Error" reported in #381 with same log message. I was able to work around the problem by starting jlab from the command line after explicit activation of the Python environment:

C:\Users\ukoethe> C:\JupyterLab\resources\jlab_server\condabin\activate
(base) C:\Users\ukoethe> jlab .

The same was necessary in order to use a custom Python environment. Merely adding the path to the Python environment as described here is not sufficient! Once again, the environment must first be activated, e.g.:

C:\Users\ukoethe> activate my_env   # assuming conda is in the PATH
(my_env) C:\Users\ukoethe> jlab .

On Windows, the activate command adds about 7 directories to the PATH variable, and jupyter will not work properly without these settings. The workaround suggested in https://github.com/jupyterlab/jupyterlab-desktop/issues/381#issuecomment-1006790158 (copy some DLLs to other directories) is not the correct solution.

I suggest to add the appropriate activate call at the beginning of JupyterLab.exe.

On a related note, in some cases the JupyterLab GUI opened, but was unable to start the kernel. After some time-out period, the status bar displayed Python 3 | Disconnected. Then, running a cell had no effect except for advancing to the next cell, as described in #386. Once again, activating the environment properly before running JupyterLab fixed this problem.

ukoethe avatar Jan 07 '22 15:01 ukoethe

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

welcome[bot] avatar Jan 07 '22 15:01 welcome[bot]

Thank you @ukoethe this is a very valuable observation. I really appreciate you taking time to experiment and figure out the problem and the solution.

krassowski avatar Jan 07 '22 19:01 krassowski

I can confirm that the solution in the OP works.

Installation version: v3.2.5-2 installed via the Windows Installer Options: Just me + Installation directory: C:\JupyterLab

Initially, I could not start JupyterLab Desktop due to #381. Then, I followed the instructions in the OP (I have no custom Python installation):

C:\Users\ukoethe> C:\JupyterLab\resources\jlab_server\condabin\activate
(base) C:\Users\ukoethe> jlab .

Now, JupyterLab Desktop opens.

aravindh-krishnamoorthy avatar Jan 12 '22 09:01 aravindh-krishnamoorthy

I also agree that this workaround works - I'm part of a class that is learning to code for the first time, and the CMD Line solution does work, it's also hard for many of my classmates to understand/work with. Hopefully there's a way to integrate this?

yellowincarnate avatar Jan 12 '22 19:01 yellowincarnate

Seems both issues "Server Initialization Error" and "Cannot connect to Kernel" originate from same source. This solved both problems for v3.2.5-2 installed via the Windows Installer. Both issues are independent of option current user/all users choosen within install.

My hack is to execute jlab from this file now (save as JupyterLab.bat):

CALL C:\JupyterLab\resources\jlab_server\condabin\activate
start C:\JupyterLab\JupyterLab.exe

MichaDit avatar Jan 13 '22 13:01 MichaDit

The solution by @MichaDit represents a good way to be able to have a file that is clickable to launch JupyerLab. 👍

Seems both issues "Server Initialization Error" and "Cannot connect to Kernel" originate from same source. This solved both problems for v3.2.5-2 installed via the Windows Installer. Both issues are independent of option current user/all users choosen within install.

My hack is to execute jlab from this file now (save as JupyterLab.bat):

CALL C:\JupyterLab\resources\jlab_server\condabin\activate
start C:\JupyterLab\JupyterLab.exe

antunderwood avatar Jan 19 '22 10:01 antunderwood

The solution by @MichaDit represents a good way to be able to have a file that is clickable to launch JupyerLab.

Indeed, and that's also what I do right now. But including the activation into JupyterLab.exe itself would be preferable.

ukoethe avatar Jan 19 '22 12:01 ukoethe

@ukoethe @MichaDit @antunderwood @yellowincarnate @aravindh-krishnamoorthy could you test the v3.2.9-1 release candidate for this issue? https://github.com/jupyterlab/jupyterlab-desktop/releases/tag/v3.2.9-1

mbektas avatar Feb 21 '22 16:02 mbektas

@ukoethe @MichaDit @antunderwood @yellowincarnate @aravindh-krishnamoorthy could you test the v3.2.9-1 release candidate for this issue? https://github.com/jupyterlab/jupyterlab-desktop/releases/tag/v3.2.9-1

Besides missing installer signature, everything seems to work fine on Win10. Thx for providing the update (and JLab Desktop as a whole) @mbektas!

Edit: Sometimes there is JS error on start and JLab cannot connect to kernel: JLab JS error

MichaDit avatar Feb 22 '22 08:02 MichaDit

thanks for testing @MichaDit! Are you getting that JS error randomly or do you have steps to reproduce?

mbektas avatar Feb 22 '22 16:02 mbektas

Randomly, cannot figure out any steps to reproduce @mbektas

MichaDit avatar Feb 23 '22 21:02 MichaDit

thanks @MichaDit. I was also able to reproduce randomly and have been debugging this issue for days. The server appears to be crashing when making websocket connections, but I couldn't trace the source of the crash (checked available logs and call stacks). It happens only at initial launch time and only when server is launched from the electron app. I couldn't find the source of the crash but as a remedy I am restarting the server if it crashes. Once you get the error as in https://github.com/jupyterlab/jupyterlab-desktop/issues/388#issuecomment-1047526190, you can restart the kernel now.

mbektas avatar Feb 27 '22 18:02 mbektas

@ukoethe could you test with the latest version and update the issue if it fixes the problem or not? https://github.com/jupyterlab/jupyterlab-desktop/releases/tag/v3.3.2-1

mbektas avatar Mar 22 '22 16:03 mbektas

closing since no response for long. please retest with latest and create new issue if necessary.

mbektas avatar Feb 26 '23 19:02 mbektas