Search code examples
pythonjupyter-notebookjupyterubuntu-19.04

Jupyter "500: Internal Server Error"; "ImportError: cannot import name ConverterMapping"


I'm trying to use Jupyter notebook on a fresh install of Ubuntu 19.04. I've run through the usual installation steps, but Jupyter does not work. When I try to open a notebook, I get

500 : Internal Server Error

When I look in the terminal, I see that Jupyter has encountered the error

ImportError: cannot import name ConverterMapping

I've searched, and found questions/answers for other causes of the internal server error in Jupyter, but I cannot find a way to fix the ConverterMapping issue. I have tried uninstalling (pip uninstall ...) and reinstalling (pip install --user ...) all Jypyter-related packages, but it had no effect.

Update:

After routine system updates, the problem has returned. This indicates to me that deleting the .local directory of pip installed packages (and then reinstalling) is not necessarily a long-term fix, since it seems like automatic updates can cause the problem to re-emerge. It's also possible that some other package (installed via apt), while not explicitly relating to python, has altered the python environment in some way that breaks Jupyter notebooks.

Any ideas or suggestions would be greatly appreciated.


Solution

  • I had a similar experience and found Mrule's answer. The deleting/renaming .local worked for me too but his long term solution didn't sadly. So I dug a little deep to find why the first solution worked.

    Turns out which jupyter returned $HOME/.local/bin/jupyter when .local was not deleted and /usr/bin/jupyter when I did. So the problem was in the pip packages (the ones installed in .local by the pip install --user jupyter option).

    I had previously did sudo pip uninstall jupyter several times before, but that doesn't remove the packages in .local (see here). You have to do pip uninstall jupyter without sudo to uninstall those in the home directory (or manually delete them). I uninstalled any other jupyter related packages in my system by finding them using pip list | grep jupyter and apt list | grep jupyter.

    And then finally did a fresh install of jupyter via sudo apt install jupyter. And now it seems to be working.

    Bottom line is that the packages installed via pip system wide and in the home directory (.local) and that installed via apt were conflicting somehow (I couldn't find exactly why).