13

I am running Anaconda3 locally via web browser. Everytime I go to the "Conda" section to see the packages that are installed (at http://localhost:8888/tree#conda) I get An error occurred while retrieving installed packages. Internal Server Error.

Checking the logs, this is what is currently happening. Any ideas?

[E 13:53:08.195 NotebookApp] 500 GET /conda/environments/root?_=1484574786374 (127.0.0.1) 760.41ms referer=http://localhost:8888/tree?
[E 13:53:14.557 NotebookApp] Unhandled error in API request
    Traceback (most recent call last):
      File "/root/anaconda3/lib/python3.5/site-

    packages/notebook/base/handlers.py", line 503, in wrapper
            result = yield gen.maybe_future(method(self, *args, **kwargs))
          File "/root/anaconda3/lib/python3.5/site-packages/nb_conda/handlers.py", line 62, in get
            self.finish(json.dumps(self.env_manager.env_packages(env)))
          File "/root/anaconda3/lib/python3.5/site-packages/nb_conda/envmanager.py", line 124, in env_packages
            "packages": [pkg_info(package) for package in data]
          File "/root/anaconda3/lib/python3.5/site-packages/nb_conda/envmanager.py", line 124, in <listcomp>
            "packages": [pkg_info(package) for package in data]
          File "/root/anaconda3/lib/python3.5/site-packages/nb_conda/envmanager.py", line 16, in pkg_info
            name, version, build = s.rsplit('-', 2)
        AttributeError: 'dict' object has no attribute 'rsplit'
    [E 13:53:14.558 NotebookApp] {
          "Accept-Language": "en-US,en;q=0.8,es;q=0.6",
          "Connection": "keep-alive",
          "X-Requested-With": "XMLHttpRequest",
          "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
          "Accept-Encoding": "gzip, deflate, sdch, br",
          "Cookie": "_xsrf=2|0e84028c|becasdfafdssffjkafdsjkf473451bfcb|1484574343; username-localhost-8888=\"2|1:0|10:1484574347|23:username-localhost-8888|44:ODBlMWE5Mjk1MjRiNDNmNDhkZTVkNTU5MGI3NTNmNDQ=|83dad5a9e1aa2da460539882d41f5b3a7ac93163dab3b324526b730be88d7d69\"",
          "Referer": "http://localhost:8888/tree?",
          "Host": "localhost:8888",
          "Accept": "application/json, text/javascript, */*; q=0.01"
        }
    [E 13:53:14.559 NotebookApp] 500 GET /conda/environments/root?_=1484574792779 (127.0.0.1) 750.79ms referer=http://localhost:8888/tree?
  • 9
    I had the same problem when trying to manage kernels for different environments. Installing `nb_conda_kernels` seemed to have fixed it for me: `conda install -c conda-forge nb_conda_kernels` – motivic Jan 16 '17 at 16:31
  • 1
    This solved my problem. Thanks! –  Jan 16 '17 at 17:40
  • 1
    @motivic You should convert it to an answer actually. It helped me too... – Benjamin Jan 23 '17 at 04:14
  • 1
    @Benjamin Based on motivic's idea, I've created [an answer](https://stackoverflow.com/a/44691762/3345375). It helped me as well! – jkdev Jun 22 '17 at 06:33

4 Answers4

7

Maybe this should be a comment, but I don't have enough reputation for those.

This is a reported bug in nb_conda. The format of the output of conda's package info has changed and nb_conda has to be adapted. There already is a pull request that fixes this but I couldn't find the change in any channel.

Installing the branch including the fix helps for now:

pip install git+https://github.com/Anaconda-Platform/nb_conda.git@d488d9e --upgrade

The --upgrade is optional, I needed it because what I had installed had the same version.

Installing nb_conda_kernels (which might have pulled in nb_conda as a dependency) from the conda-forge channel as mentioned by motivic did not help in my case, but should work if the package there contains the fix.

Community
  • 1
  • 1
Jan
  • 238
  • 2
  • 7
  • I'm getting this error, regardless of pulling the branch with the fix. – Ryder Bergerud Mar 18 '17 at 00:33
  • Is there a way I can still set the default environment with conda for jupyter notebook? – Ryder Bergerud Mar 18 '17 at 00:35
  • @RyderBergerud I can't really help you without further information, the fix is in the branch and works for me. I'd also assume, that jupyter is not executing in the right environment. See [this other question](http://stackoverflow.com/questions/37085665/in-which-conda-environment-is-jupyter-executing) for conda environments and jupyter. – Jan Mar 19 '17 at 13:16
  • 2
    Just a small note, the branch was deleted 3 days ago after the PR to fix it was merged, so the proper way to install is now `pip install git+https://github.com/Anaconda-Platform/nb_conda.git@d488d9e --upgrade` – Jakub Arnold Apr 30 '17 at 00:00
2

Motivic's suggestion (in his comment on the question) worked for me.

$ conda install -c conda-forge nb_conda_kernels

I already had an older version of nb_conda_kernels, so it updated to 2.1.0.

The following packages will be UPDATED:
    nb_conda_kernels: 2.0.0-py27_0 --> 2.1.0-py27_0 conda-forge

The Conda tab in Jupyter Notebook worked fine after that. I was also able to conda install pandas which had been giving me an error earlier.

jkdev
  • 11,360
  • 15
  • 54
  • 77
2

I too was having this issue (conda 4.3.25, Linux Mint 17.2 Rafaela, Ubuntu 14.04.2 LTS, Trusty Tahr). I attempted the usual update remedies to no avail so I patched the code on line 16 of .../site-packages/nb_conda/envmanager.py.

    name, version, build = s.rsplit('-', 2)

becomes:

    if isinstance(s, dict):
        s = s['dist_name']
    name, version, build = s.rsplit('-', 2) 

This was helpful to me, YMMV. Note that the current envmanager.py in Github has a similar fix based on the dictionary contents.

1

While I clicked the conda tab in Jupyter Notebook, it always threw the same error as you had.

All the solutions on Stackoverflow and github can't help me out, so in desperation I found on the Anaconda Doc this line (on the Doc page of conda extension):

NOTE: These extensions were already installed in Anaconda versions 4.1 and 4.2. If you have Anaconda v4.1 or v4.2 installed, there is no need to install them separately. To begin using them, open a new or existing notebook.

Check whether your Anaconda is later than version 4.2. Mine is 4.4.0.

W.Zhan Lesson 1 Data Analysis Process $ conda remove nb_conda
Fetching package metadata .........
Solving package specifications: .

Package plan for package removal in environment /Users/W.Zhan/anaconda:

The following packages will be REMOVED:

    _nb_ext_conf:     0.4.0-py36_1
    nb_anacondacloud: 1.4.0-py36_0
    nb_conda:         2.2.0-py36_0
    nbpresent:        3.0.2-py36_0

Proceed ([y]/n)? y

W.Zhan Lesson 1 Data Analysis Process $ python --version
Python 3.6.1 :: Anaconda 4.4.0 (x86_64)

Thus I uninstalled conda in terminal, and just activate the environment I wanted to use and in that particular environment, open Jupyter.

W.Zhan Lesson 1 Data Analysis Process $ source activate DAND
(DAND) W.Zhan Lesson 1 Data Analysis Process $ jupyter notebook

Not sure whether this can solve your problem, for me, although there is no more 'conda' tab in Jupyter, but as long as I can use customized environment in Jupyter, I am fine with that.

Hope it helps.

YC_
  • 329
  • 2
  • 9