millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

ein:use-none-backend failed with Jedi.el #608

Closed yatsky closed 5 years ago

yatsky commented 5 years ago

Problem description

I'm not very famaliar with the technicalities but will try my best to describe it.

As per instructions in the ein doc, I set "ein:use-none-backend" and installed jedi in the conda environment.

I can confirm that auto-completion works when I edit a single .py file (I can get a pop-up list). However, when I open a notebook, at first the auto-complete minor mode is on, which I can see from the mini bar, then when I type something like pandas., the auto-complete minor mode disappears and give me this error message auto-complete error: (error cl-ecase failed: ein:use-none-backend, (ein:use-ac-backend)).

When I run M-x auto-complete-mode /again/, and try to run the same command, then I will get this error deferred error : (error "cl-ecase failed: ein:use-none-backend, (ein:use-ac-backend)").

I tried to use EIN's debug mode but had no luck. Everything looks normal until the error message was logged.

Steps to reproduce the problem

I did pip install jedi in the conda environment a long time ago. Install EIN from MELPA. Install Jedi.el via MELPA. Run M-x jedi:install-server in Emacs. Run M-x set-variable RET ein:polymode RET. Set ein:polymode to t. Restart Emacs. Run M-x ein:run. Open a notebook. Run

import os
os.

And get the error message auto-complete error: (error cl-ecase failed: ein:use-none-backend, (ein:use-ac-backend)).

Here's my jedi settings.

;; jedi
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)    ;optional

Here's my ein settings.

; ein
(require 'ein)
(require 'ein-notebook)
(require 'ein-subpackages)
(setq ein:completion-backend 'ein:use-none-backend)

System info:

("EIN system info"
 :emacs-version "GNU Emacs 26.2 (build 1, x86_64-w64-mingw32)
 of 2019-04-13"
 :emacs-bzr-version "fd1b34bfba8f3f6298df47c8e10b61530426f749"
 :window-system w32
 :emacs-variant nil
 :os
 (:uname "MSYS_NT-10.0 username-PC 2.10.0(0.325/5/3) 2018-06-13 23:34 x86_64 Msys
"
     :lsb-release nil)
 :notebook
 "Name: notebook
Version: 5.7.8
Summary: A web-based notebook environment for interactive computing
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.com
License: BSD
Location: c:\\users\\username\\appdata\\local\\conda\\conda\\envs\\python-for-finance\\lib\\site-packages
Requires: terminado, ipython-genutils, Send2Trash, prometheus-client, pyzmq, tornado, nbconvert, traitlets, nbformat, jupyter-core, jinja2, jupyter-client, ipykernel
Required-by: widgetsnbextension, jupyter
"
 :ipython "7.4.0
"
 :image-types
 (svg png gif tiff jpeg xpm xbm pbm)
 :image-types-available
 (svg png gif tiff jpeg xpm xbm pbm)
 :request
 (:backend curl)
 :ein
 (:version "0.16.2.2"
       :source-dir "c:/Users/username/.emacs.d/elpa/ein-0.16.2.2/")
 :lib
 ((:name "websocket"
     :path "~/.emacs.d/elpa/websocket-1.11.1/websocket.elc"
     :featurep t
     :version-var websocket-version
     :version "1.11.1")
  (:name "auto-complete"
     :path "~/.emacs.d/elpa/auto-complete-1.5.1/auto-complete.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "request"
     :path "~/.emacs.d/elpa/request-0.3.1/request.elc"
     :featurep t
     :version-var request-version
     :version "0.3.0")
  (:name "deferred"
     :path "~/.emacs.d/elpa/deferred-0.5.1/deferred.elc"
     :featurep t
     :version-var deferred:version
     :version "0.5.0")
  (:name "polymode"
     :path "~/.emacs.d/elpa/polymode-0.2/polymode.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "markdown-mode"
     :path "~/.emacs.d/elpa/markdown-mode-2.3/markdown-mode.elc"
     :featurep t
     :version-var markdown-mode-version
     :version "2.3")
  (:name "dash"
     :path "~/.emacs.d/elpa/dash-2.16.0/dash.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "s"
     :path "~/.emacs.d/elpa/s-1.12.0/s.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "skewer-mode"
     :path "~/.emacs.d/elpa/skewer-mode-1.8.0/skewer-mode.elc"
     :featurep t
     :version-var nil
     :version nil)))
millejoh commented 5 years ago

Commit 55da136a271295153e61ef8f1fb834c2153f1396 gets rid of the error. Interestingly, although ein:polymode is active and ein:completion-backend is telling ein not to use any of its custom backends, code in ein-ac.el is still being executed. Part of the code is a call to cl-ecase which is generating the error you see. Everything is wrapped in a call to deferred, which sends most of the useful debugging information (like an actual backtrace) into la-la land.

I haven't merged this into master just yet as based on my limited testing it looks like this gets some of the desired completion behaviour back, but not all. ein-ac.el is still overriding some of the behavior provided by jedi and python-mode.

Removing ein's home-grown support for auto-complete is a solution - but I prefer to deprecate functionality over outright deletion. I'd like to come up with a suitable solution (and maybe even some test cases) before merging anything into master.

On that note - I see you are downloading from stable. Note that with travis-CI the master branch will generally be just as stable, if not more so than any tagged releases.

yatsky commented 5 years ago

Thanks @millejoh . It's great to know that the issue has been found and solved.

So if I want to use the master branch, do I need to manually install it or is it possible to use MELPA to install the master branch? Thanks!