Skip to content

JupyterLab on Windows does not properly activate conda environment #388

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

Closed
ukoethe opened this issue Jan 7, 2022 · 14 comments
Closed

JupyterLab on Windows does not properly activate conda environment #388

ukoethe opened this issue Jan 7, 2022 · 14 comments
Labels

Comments

@ukoethe
Copy link

ukoethe commented Jan 7, 2022

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 #381 (comment) (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 ukoethe added the bug label Jan 7, 2022
@welcome
Copy link

welcome bot commented Jan 7, 2022

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

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! 👋

Welcome to the Jupyter community! 🎉

@krassowski
Copy link
Member

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.

@aravindh-krishnamoorthy
Copy link

aravindh-krishnamoorthy commented Jan 12, 2022

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.

@yellowincarnate
Copy link

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?

@MichaDit
Copy link

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
Copy link

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

@ukoethe
Copy link
Author

ukoethe commented Jan 19, 2022

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.

@mbektas
Copy link
Member

mbektas commented Feb 21, 2022

@MichaDit
Copy link

MichaDit commented Feb 22, 2022

@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

@mbektas
Copy link
Member

mbektas commented Feb 22, 2022

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

@MichaDit
Copy link

Randomly, cannot figure out any steps to reproduce @mbektas

@mbektas
Copy link
Member

mbektas commented Feb 27, 2022

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 #388 (comment), you can restart the kernel now.

@mbektas
Copy link
Member

mbektas commented Mar 22, 2022

@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
Copy link
Member

mbektas commented Feb 26, 2023

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

@mbektas mbektas closed this as completed Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants