question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JupyterLab on Windows does not properly activate conda environment

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ukoethecommented, 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.

1reaction
mbektascommented, 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 https://github.com/jupyterlab/jupyterlab-desktop/issues/388#issuecomment-1047526190, you can restart the kernel now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conda environments not showing up in Jupyter Notebook
In summary, after installing ipykernel , you must activate each conda environment one by one in a terminal and run the command python...
Read more >
Get Your Conda Environment to Show in Jupyter Notebooks
1. First, install nb_conda_kernels in your base environment. Once this is installed any notebook running from the base environment will ...
Read more >
Why I can't do 'conda activate <env>' in JupyterLab?
I am using Jupyter lab, I can use conda command such as: conda list conda info --envs pip list. but I cannot use...
Read more >
Installation — JupyterLab 3.6.0b0 documentation
JupyterLab can be installed using conda , mamba , pip , pipenv or docker . ... When using pipenv , in order to...
Read more >
Getting Started with Conda – Introduction to Python for Data ...
Activating environments is essential to making the software in environments work well (or sometimes at all!). Activation of an environment does two things....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found