nb_conda icon indicating copy to clipboard operation
nb_conda copied to clipboard

Erroneous Environments Showing up in Conda Nb tab with error

Open joethequant opened this issue 6 years ago • 30 comments

Not sure how to fix this, or how it got corrupted.

Error Message: EnvironmentLocationNotFound: Not a conda environment

Pics Below: image

image

joethequant avatar Dec 28 '17 13:12 joethequant

Seems this could be related to conda instal plotly which upgraded conda and anaconda. Does anyone think that is related?

joethequant avatar Dec 28 '17 19:12 joethequant

Okay this looks like there is actually a bigger issue with the new anaconda version. Conda_NB is not compatible with newest versions of Anaconda and Conda.

joethequant avatar Dec 28 '17 21:12 joethequant

The reason is the change of conda info --json output. Fresh installation of version 4.3.33 gives envs=[], version >=4.4 gives envs=[root_env_dir] (always non empty). Fix: Replace for env in info['envs']] with for env in info['envs'] if env != info['root_prefix']] in nb_conda/envmanager.py. You may do it in anaconda_dir/pkgs/nb_conda-2.2.1-py36h8118bb2_0/lib/python3.6/site-packages/nb_conda/envmanager.py on your machine, if you don't want to wait for update. At least it removes annoying error message and kernels list entry in "Conda" tab.

Variety of kernels in the "New" button is still here, though.

voidworker avatar Feb 05 '18 20:02 voidworker

The above method solved the problem. Just remember to change your path anaconda_dir/pkgs/nb_conda-2.2.1-py36h8118bb2_0/lib/python3.6/site-packages/nb_conda/envmanager.py to your local setting.

But keep the for env in info['envs'] if env != info['root_prefix']]

wonderlives avatar Feb 08 '18 23:02 wonderlives

The method worked for me too, but the path should be anaconda_dir/lib/python3.6/site-packages/nb_conda/envmanager.py

jyepesr1 avatar Apr 03 '18 15:04 jyepesr1

Had the same problem, and fixed it modifying the envmanager.py file in the directory pointed out by jyepesr1.

Should a pull request be done to fix this?

lucainnocenti avatar May 01 '18 14:05 lucainnocenti

Yes, just modify the envmanager.py file, which can fix the problem.

ZenRay avatar May 30 '18 09:05 ZenRay

I added @voidworker's fix to pull request #75, which also fixes some other issues with conda>=4.4

tjd2002 avatar May 30 '18 20:05 tjd2002

Hi, I have the same issue with the same error message. I have conda 4-5-4 and Jupyter 5.5.0

My environment in Anaconda Navigator works well shows the right one as in Conda terminal.

But in Jupyter, tab Conda, I have got the same issue as above.

  1. I modify the envmanager.py as mentionned above (with voidworker and jyepesr1 path) and now... the envronment list in Jupyter is empty :( ! with this message:

An error occurred while listing Conda environments. Not Found

  1. I reinstalled Anaconda, always the issue!

Please, note I think this problem come from the "Clone" fonction in Anaconda Navigator. I wanted to clone the Root environment in order to copy it as a new fixed environment :( I think it is a bad idea!

(The next time, I will create a new environment and I will install Anaconda and the packages I need :).

------------ The complete error message: ----------------- [I 18:13:06.057 NotebookApp] [nb_conda_kernels] enabled, 6 kernels found [I 18:13:07.182 NotebookApp] JupyterLab beta preview extension loaded from C:\Anaconda3\lib\site-packages\jupyterlab [I 18:13:07.182 NotebookApp] JupyterLab application directory is C:\Anaconda3\share\jupyter\lab [W 18:13:07.633 NotebookApp] Error loading server extension nb_conda Traceback (most recent call last): File "C:\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1481, in init_server_extensions mod = importlib.import_module(modulename) File "C:\Anaconda3\lib\importlib_init_.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in call_with_frames_removed File "C:\Anaconda3\lib\site-packages\nb_conda_init.py", line 3, in from .handlers import load_jupyter_server_extension File "C:\Anaconda3\lib\site-packages\nb_conda\handlers.py", line 25, in from .envmanager import EnvManager, package_map File "C:\Anaconda3\lib\site-packages\nb_conda\envmanager.py", line 85 for env in info['envs'] if env != info['root_prefix']]] ^ SyntaxError: invalid syntax [I 18:13:07.791 NotebookApp] Serving notebooks from local directory: C:\Users\RLE [I 18:13:07.792 NotebookApp] 0 active kernels [I 18:13:07.792 NotebookApp] The Jupyter Notebook is running at: [I 18:13:07.792 NotebookApp] http://localhost:8888/?token=51c96d41a92da45efd892bba3c2b29fb06679f123587f704 [I 18:13:07.792 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 18:13:07.795 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:8888/?token=51c96d41a92da45efd892bba3c2b29fb06679f123587f704&token=51c96d41a92da45efd892bba3c2b29fb06679f123587f704 [I 18:13:07.859 NotebookApp] Accepting one-time-token-authenticated connection from ::1 [W 18:13:11.938 NotebookApp] 404 GET /conda/environments?=1529856788669 (::1) 23.00ms referer=http://localhost:8888/tree [W 18:13:11.946 NotebookApp] 404 GET /conda/packages/available?=1529856788670 (::1) 4.00ms referer=http://localhost:8888/tree


Please note too that Jupyter works perfectly (except conda tab).

image

Thank you for your time.

José.

jrd10 avatar Jun 24 '18 16:06 jrd10

Please note I installed

  • nb_conda (2.2.1)
  • and nb_conda_kernels (2.1.0) from conda-forge...

I wonder if it has been a good idea

José

jrd10 avatar Jun 24 '18 16:06 jrd10

We are working on upgrading our JupyterHub instance to use version 0.9.1 and Conda version 4.5.8.

If, after a fresh Conda install, we attempt to use the root/base environment we see the error in https://github.com/Anaconda-Platform/nb_conda/issues/66, but we have worked around that by creating a new Conda environment specifically for JupyterHub.

As an example: conda create -n jupyterhub python=3 jupyterhub=0.9.1

xpros avatar Jul 20 '18 14:07 xpros

I've got a PR here (#75) that includes @voidworker's fix for this, as well as some other Conda 4.4 issues, but there doesn't seem to be much movement on it. @fjcapdevila are you still a maintainer?

@jrelland it looks like you just made a typo when manually applying the fix: In the line marked as containing a 'Syntax error' there's an extra square bracket at the end of the line.

tjd2002 avatar Jul 20 '18 15:07 tjd2002

voidworker's fix solved problem, and don't forget to restart jupyter notbook.

sngjuk avatar Oct 01 '18 08:10 sngjuk

The method worked for me too, but the path should be anaconda_dir/lib/python3.6/site-packages/nb_conda/envmanager.py

where can i do that ?

Wafaashabrawishi avatar Mar 19 '19 13:03 Wafaashabrawishi

Any plans to get this fixed once for all?

lduhem avatar May 14 '19 13:05 lduhem

More than a year an a half in..can we get this bug fixed?

shailensobhee avatar Jul 08 '19 00:07 shailensobhee

Yes, just modify the envmanager.py file, which can fix the problem.

how to do all of this?? Can u elaborate it?

avipeddi avatar Sep 20 '19 12:09 avipeddi

I fix the envmanager.py, but it seems appears one new bug’ EnvironmentLocationNotFound’. Not a good thing to me...

leoyinhaiqing avatar Oct 02 '19 15:10 leoyinhaiqing

I'm getting this error after applying the for env in info['envs'] if env != info['root_prefix']] fix.

Screenshot 2019-10-30 00 06 41

DerekChia avatar Oct 29 '19 16:10 DerekChia

Another super-duper tip: consider switching to to https://github.com/fcollonval/jupyter_conda :)

voidworker avatar Nov 08 '19 21:11 voidworker

The method worked for me too, but the path should be anaconda_dir/lib/python3.6/site-packages/nb_conda/envmanager.py

where can i do that ?

please have you been able to do this

EuniceOyeniyi avatar Apr 02 '20 11:04 EuniceOyeniyi

The method worked. Funny - this bug still exist as of today.

marcellovirzi avatar Apr 23 '20 10:04 marcellovirzi

@marcellovirzi nothing really funny about it, this extension is completely abandoned by the anaconda team. No commit since July 2017...

zertrin avatar Apr 23 '20 11:04 zertrin

@marcellovirzi nothing really funny about it, this extension is completely abandoned by the anaconda team. No commit since July 2017...

Yeah, I was ironic...

marcellovirzi avatar Apr 24 '20 07:04 marcellovirzi

Resolved this issue by replacing for env in info['envs']] with for env in info['envs'] if env != info['root_prefix']] in /opt/conda/lib/python3.8/site-packages/nb_conda/envmanager.py. Replacing these string in /opt/conda/pkgs/nb_conda-2.2.1-py38h32f6830_4/lib/python3.8/site-packages/nb_conda/envmanager.py did not help me.

After this I have only one default environment root and no annoying message.

sentinel09 avatar Nov 29 '20 18:11 sentinel09

Can someone please explain the solution as simple as possible. I'm almost pulling my hair out trying to figure out where 'for env in info[ 'envs' ] ] is and how to replace it with 'for env in info[ 'envs' ] if env != info[ 'root_prefix' ] ] in /opt/conda/lib/python3.8/site-packages/nb_conda/envmanager.py. Someone help please.

wolfofsiliconvalley avatar Jan 08 '21 15:01 wolfofsiliconvalley

Solved! Thanks

wolfofsiliconvalley avatar Jan 09 '21 13:01 wolfofsiliconvalley

None of this worked for me as my issue was slightly different, but I found the removed environment that was being returned in the error was stored in the environment variable $CONDA_PREFIX. After exporting a new $CONDA_PREFIX (or relaunching terminal), the error went away.

schultzm avatar Feb 04 '21 01:02 schultzm

@schultzm Are you working in Linux OS? I searched for that environment variable on Windows 10 and cannot find it.

richlysakowski avatar Mar 29 '21 02:03 richlysakowski

nb_conda is unsupported ?

The directory referenced in another to manually fix it does not exist on Windows 10.

anaconda_dir/lib/python3.6/site-packages/nb_conda/envmanager.py

richlysakowski avatar Mar 29 '21 03:03 richlysakowski