Doom-emacs: Not working autocompletion in python-mode

Created on 20 Jan 2018  路  14Comments  路  Source: hlissner/doom-emacs

Observed behavior

I have in the settings

(require 'company)
(setq company-idle-delay 0.2
      company-minimum-prefix-length 3)

When I open *.py autocompletion not working.
2018-01-21 0 28 42

Expected behaviour

Autocompletion works when I open the file the first time.
2018-01-21 0 28 58

Steps to reproduce

  1. Create and open test.py file
  2. Run describe-variable company-backends. Its value is (company-capf company-dabbrev company-ispell company-yasnippet)
  3. Run python-mode and again describe-variable company-backends. Current value is ((company-anaconda) company-capf company-dabbrev company-ispell company-yasnippet)

    System information


Click to expand

DOOM Doctor
Running Emacs v25.3.1, commit 5dacbb7cb1c6ac246a9ccd15e6c4290def67757c

shell: /bin/zsh
Compiled with:
  JPEG RSVG IMAGEMAGICK NOTIFY ACL GNUTLS LIBXML2 ZLIB
  TOOLKIT_SCROLL_BARS NS MODULES
uname -a:
  Darwin MacBook-Air-Aleksandr.local 17.0.0 Darwin Kernel Version
  17.0.0: Thu Aug 24 21:48:19 PDT 2017;
  root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64

Attempt to load DOOM: success! Loaded v2.0.9
Revision 5dacbb7cb1c6ac246a9ccd15e6c4290def67757c

----

test-emacs
test-windows
test-fonts
Found font material-design-icons.ttf
Found font weathericons.ttf
Found font octicons.ttf
Found font fontawesome.ttf
Found font file-icons.ttf
Found font all-the-icons.ttf
test-gnutls
test-tls
Validated https://elpa.gnu.org
Validated https://melpa.org
Successfully rejected https://self-signed.badssl.com
Successfully rejected https://wrong.host.badssl.com/
test-tar
Everything seems fine, happy Emacs鈥檌ng!

bug resolved

All 14 comments

Found the issue and fixed it in develop. I'll keep this open until it hits master. Thanks for letting me know!

I did a fresh install from the dev branch and still it doesn't work out of the box.

@Githeo Did you enable both :completion company and :lang python (or the module for the programming language you are testing with)?

Hello @filalex77, in the .doom/init.el file the:completion companywas already enabled and I enabled the :lang pythontoo. Still no completion.
Do I need to run some other commands before?

Did you run doom refresh after enabling said modules? @Githeo

just did it and I also add in the init.el

(require 'company)
(setq company-idle-delay 0.2
      company-minimum-prefix-length 3)

with no luck.

The only way so far to make it work is to disable global-company-mode and then to re-enable it at each time I open emacs. It's annoying.

Hello @filalex77, in the .doom/init.el file the:completion companywas already enabled and I enabled the :lang pythontoo. Still no completion.
Do I need to run some other commands before?

the same problem.

@alinbxSorcerer Is there any way you can get completion working (for example, by restarting global-company-mode)? If not, please try manually installing dependencies for anaconda-mode (the Python backend for Emacs used by :lang python):

pip install jedi json-rpc service_factory

Be sure to check your Python version (for example, to use pip3 for Python 3), whether you have permissions for a system-wide installation (sudo pip install or pip install --user may work, but please consult the documentation for your OS of choice).

If that doesn't help, please let me know, and also describe your environment in more detail. Pasting the output of M-x doom/info RET would be a good start. Good luck!

@alinbxSorcerer Is there any way you can get completion working (for example, by restarting global-company-mode)? If not, please try manually installing dependencies for anaconda-mode (the Python backend for Emacs used by :lang python):

pip install jedi json-rpc service_factory

Be sure to check your Python version (for example, to use pip3 for Python 3), whether you have permissions for a system-wide installation (sudo pip install or pip install --user may work, but please consult the documentation for your OS of choice).

If that doesn't help, please let me know, and also describe your environment in more detail. Pasting the output of M-x doom/info RET would be a good start. Good luck!

It does not work and the details.

emacs   version    26.1
        features   XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2
        build      Apr 11, 2019
        buildopts  (--build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs-cQxEw2/emacs-26.1+1=. -fstack-protector-strong -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro')
        windowsys  x
        daemonp    server-running
doom    version    2.0.9
        build      HEAD -> develop, origin/develop, origin/HEAD 7c8badc8f 2019-09-28 12:47:21 -0400
system  type       gnu/linux
        config     x86_64-pc-linux-gnu
        shell      /bin/bash
        uname      Linux 5.0.0-27-generic #28-Ubuntu SMP Tue Aug 20 19:53:07 UTC 2019 x86_64
        path       (~/anaconda3/bin ~/anaconda3/bin ~/anaconda3/bin ~/anaconda3/bin ~/anaconda3/condabin ~/anaconda3/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin ~/.emacs.d/bin ~/.emacs.d/bin ~/.emacs.d/bin ~/.emacs.d/bin /usr/lib/emacs/26.1/x86_64-linux-gnu/)
config  envfile    envvar-file
        elc-files  0
        modules    (:completion company helm ivy :ui doom doom-dashboard doom-quit hl-todo modeline nav-flash ophints (popup +all +defaults) vc-gutter vi-tilde-fringe window-select workspaces :editor file-templates fold multiple-cursors rotate-text snippets :emacs dired electric vc :term eshell shell term :tools eval flycheck (lookup +docsets) magit :lang data emacs-lisp markdown (org +dragndrop +ipython +pandoc +present) python sh :config (default +bindings +smartparens))
        packages   (n/a)
        elpa       (n/a)

```

  • OS: darwin (x86_64-apple-darwin18.6.0)
  • Shell: /usr/local/bin/fish
  • Emacs: 26.2 (Aug 07, 2019)
  • Doom: 2.0.9 (HEAD -> develop, origin/develop, origin/HEAD f754d4ff 2019-07-23 18:23:17 +0200)
  • Graphic display: t (daemon: nil)
  • System features: JPEG RSVG IMAGEMAGICK GLIB NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS LCMS2
  • Details:
    elisp env bootstrapper: envvar-file elc count: 0 uname -a: Darwin 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64 modules: (:completion company ivy :ui doom doom-dashboard doom-quit hl-todo modeline nav-flash ophints (popup +all +defaults) treemacs vc-gutter vi-tilde-fringe window-select workspaces :editor evil file-templates fold multiple-cursors rotate-text snippets :emacs dired electric vc :tools eval flycheck (lookup +docsets) magit :lang data emacs-lisp markdown (org +dragndrop +ipython +pandoc +present) python sh :config default) packages: n/a exec-path: (/usr/local/Cellar/pyenv-virtualenv/1.1.3/shims ~/.pyenv/shims /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/TeX/texbin . ~/Library/Android/sdk/platform-tools/ /usr/local/Cellar/emacs-plus/26.2/libexec/emacs/26.2/x86_64-apple-darwin18.6.0/)

@Githeo There were some changes (not necessarily related to :lang python) since 2019-07-23, would you mind running doom update?

Also, lsp-python-ms support was added. Consider setting it up, LSP is objectively better than any company backend.

@filalex77 I did the doom update. Now a completion is shown but it's the common one for all the variables only.
How could I switch to lsp-python-ms?

@Githeo

  1. Quit Emacs.
  2. Add +lsp flag to :lang python in init.el
:lang
-python
+(python +lsp)
  1. Run doom refresh.
  2. Launch Emacs. Run M-x lsp-python-ms-setup RET to install the server (it may hang for a few minutes).
  3. Try opening up a .py file and see what you get!

DISCLAIMER: this works only for files that are a part of a "project". Not sure on what a project is in terms of Python, but I just created a scaffold using poetry (poetry new my_app), and it worked with the files inside.

lsp-python-ms-setup doesn't pop up after M-x. Is it not installed?

bin/doom install lsp-python-ms
Insecure mode on
Doom core autoloads is up-to-date
Looking for packages to install...
No packages to install!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  31Comments

shuxiao9058 picture shuxiao9058  路  25Comments

zeronone picture zeronone  路  23Comments

r-darwish picture r-darwish  路  23Comments

pmercatoris picture pmercatoris  路  30Comments