Ipython kernel error after uninstalling anaconda

2020-07-30 02:51发布

问题:

I'm on ubuntu 14.04. I was running anaconda and I used the conda command (as per this post) to make both python 2 and python 3 available in ipython notebooks. But I just uninstalled anaconda and installed ipython, jupyter and notebook individually inside a virtualenv. Now when I try to create a new notebook I get the following error. As you can see in the last line, it seems to still be referring to the kernel created with anaconda which obviously doesn't exist anymore since I uninstalled anaconda.

Can someone please help me with that issue? Thanks a lot.

 Traceback (most recent call last):
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/notebook/base/handlers.py", line 458, in wrapper
    result = yield gen.maybe_future(method(self, *args, **kwargs))
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/notebook/services/sessions/handlers.py", line 58, in post
    sm.create_session(path=path, kernel_name=kernel_name))
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/notebook/services/sessions/sessionmanager.py", line 73, in create_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/tornado/gen.py", line 282, in wrapper
    yielded = next(result)
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/notebook/services/kernels/kernelmanager.py", line 87, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/jupyter_client/multikernelmanager.py", line 109, in start_kernel
    km.start_kernel(**kwargs)
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/jupyter_client/manager.py", line 244, in start_kernel
    **kw)
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/jupyter_client/manager.py", line 190, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "/home/joe/.virtualenvs/crissp/lib/python3.4/site-packages/jupyter_client/launcher.py", line 123, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/home/joe/anaconda3/envs/py27/bin/python'

回答1:

Run jupyter kernelspec list, and it should tell you where the kernelspecs were installed to. You'll need to remove the folders that are now incorrect.

Alternatively, install a new kernelspec with the ipython you have now installed, as described in the IPython docs. This will replace the kernelspec that was already installed for that version of Python.