emacsorphanage / company-jedi

Company backend for Python jedi
101 stars 12 forks source link

Deferred error #42

Closed Anoncheg1 closed 2 years ago

Anoncheg1 commented 2 years ago

Summary

Not working

Steps to reproduce

$ emacs
M-x jedi:install-server
C-x C-c
$ emacs a.py
M-x company-mode
imp
C-x b *Message* RET

deferred error : (error "\"TypeError('init() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given')\""

My configuration

env

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/13/bin:/home/user/.local/bin PYTHONPATH=/home/user/.local/lib/python3.9/dist-packages/:/home/user/.local/lib/python3.9/site-packages/

OS

GNU/Linux 5.10.76-gentoo x86_64

.emacs

(require 'package)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

(require 'jedi-core)
(require 'epc)
(require 'company)
(require 'company-jedi)

(with-eval-after-load "company-jedi"
  ;;standard-jedi-settings
  (add-hook 'python-mode-hook 'jedi:setup)
  (setq jedi:complete-on-dot t)
  (setq jedi:use-shortcuts t)
  ;;company-jedi-settings
  (setq jedi:environment-virtualenv (list (expand-file-name "~/.emacs.d/.python-environments/")))
  (defun my/python-mode-hook ()
    (add-to-list 'company-backends 'company-jedi))
  (add-hook 'python-mode-hook 'my/python-mode-hook)

  ;; backend-settings
  (setq elpy-rpc-backend "jedi")

)

message buffer

For information about GNU Emacs and the GNU system, type C-h C-a.
a.py has auto save data; consider M-x recover-this-file
Waiting for git... [2 times]
Making completion list... [2 times]
Company mode enabled in current buffer
deferred error : (error "\"TypeError('__init__() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given')\"")

pip freeze

backports.entry-points-selectable==1.1.1
certifi==10001
charset-normalizer==2.0.6
distlib==0.3.4
docutils==0.17.1
epc==0.0.5
filelock==3.4.0
gdbus_codegen==2.68.4
gemato==16.2
gentoolkit==0.5.1.post1
idna==3.3
Jinja2==3.0.2
Mako==1.1.5
MarkupSafe==2.0.1
meson==0.59.4
packaging==21.0
platformdirs==2.4.0
portage==3.0.28
Pygments==2.10.0
pyparsing==2.4.7
PySocks==1.7.1
requests==2.26.0
setuptools-scm==6.3.2
sexpdata==0.0.3
six==1.16.0
tomli==1.2.2
urllib3==1.26.7
virtualenv==20.10.0

~/.emacs.d/.python-environments $ ls ////*


~/.emacs.d/.python-environments $ ls */*/*/*/*
default/lib/python3.9/site-packages/_virtualenv.pth
default/lib/python3.9/site-packages/_virtualenv.py
default/lib/python3.9/site-packages/argparse.py
default/lib/python3.9/site-packages/distutils-precedence.pth
default/lib/python3.9/site-packages/jediepcserver.py
default/lib/python3.9/site-packages/pip-21.3.1.virtualenv
default/lib/python3.9/site-packages/setuptools-59.3.0.virtualenv
default/lib/python3.9/site-packages/wheel-0.37.0.virtualenv

default/lib/python3.9/site-packages/__pycache__:
_virtualenv.cpython-39.pyc  jediepcserver.cpython-39.pyc
argparse.cpython-39.pyc

default/lib/python3.9/site-packages/_distutils_hack:
__init__.py  __pycache__  override.py

default/lib/python3.9/site-packages/argparse-1.4.0.dist-info:
DESCRIPTION.rst  METADATA  WHEEL          top_level.txt
INSTALLER        RECORD    metadata.json

default/lib/python3.9/site-packages/jedi:
__init__.py  _compatibility.py  common.py   inference        settings.py
__main__.py  api                debug.py    parser_utils.py  third_party
__pycache__  cache.py           file_io.py  plugins          utils.py

default/lib/python3.9/site-packages/jedi-0.18.1.dist-info:
AUTHORS.txt  INSTALLER  LICENSE.txt  METADATA  RECORD  WHEEL  top_level.txt

default/lib/python3.9/site-packages/jediepcserver-0.2.8.dist-info:
INSTALLER  RECORD     WHEEL            entry_points.txt
METADATA   REQUESTED  direct_url.json  top_level.txt

default/lib/python3.9/site-packages/parso:
__init__.py        cache.py    normalizer.py  py.typed  utils.py
__pycache__        file_io.py  parser.py      python
_compatibility.py  grammar.py  pgen2          tree.py

default/lib/python3.9/site-packages/parso-0.8.3.dist-info:
AUTHORS.txt  INSTALLER  LICENSE.txt  METADATA  RECORD  WHEEL  top_level.txt

default/lib/python3.9/site-packages/pip:
__init__.py  __main__.py  __pycache__  _internal  _vendor  py.typed

default/lib/python3.9/site-packages/pip-21.3.1.dist-info:
INSTALLER    METADATA  WHEEL             top_level.txt
LICENSE.txt  RECORD    entry_points.txt

default/lib/python3.9/site-packages/pkg_resources:
__init__.py  __pycache__  _vendor  extern  tests

default/lib/python3.9/site-packages/setuptools:
 __init__.py               cli-arm64.exe   glob.py         package_index.py
 __pycache__               cli.exe         gui-32.exe      py34compat.py
 _deprecation_warning.py   command         gui-64.exe      sandbox.py
 _distutils                config.py       gui-arm64.exe  'script (dev).tmpl'
 _imp.py                   dep_util.py     gui.exe         script.tmpl
 _vendor                   depends.py      installer.py    unicode_utils.py
 archive_util.py           dist.py         launch.py       version.py
 build_meta.py             errors.py       monkey.py       wheel.py
 cli-32.exe                extension.py    msvc.py         windows_support.py
 cli-64.exe                extern          namespaces.py

default/lib/python3.9/site-packages/setuptools-59.3.0.dist-info:
INSTALLER  LICENSE  METADATA  RECORD  WHEEL  entry_points.txt  top_level.txt

default/lib/python3.9/site-packages/wheel:
__init__.py  bdist_wheel.py     metadata.py  vendored
__main__.py  cli                pkginfo.py   wheelfile.py
__pycache__  macosx_libfile.py  util.py

default/lib/python3.9/site-packages/wheel-0.37.0.dist-info:
INSTALLER    METADATA  WHEEL             top_level.txt
LICENSE.txt  RECORD    entry_points.txt
Anoncheg1 commented 2 years ago

Solved: It was jedi version missmatch: jedi-0.18.1 after downgrade to: pip install jedi==0.17.2 everything woks.

it also required pip install virtualenv

my .emacs:

(require 'jedi-core)
(require 'company-jedi)

(with-eval-after-load 'jedi-core
  ;;standard-jedi-settings
  ;; (setq jedi:environment-virtualenv (list (expand-file-name "~/.emacs.d/.python-environments/")))
  (setq jedi:environment-root "jedi")
  (setq jedi:server-command (jedi:-env-server-command))

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

(with-eval-after-load 'company-jedi
  (defun my/python-mode-hook ()
    (add-to-list 'company-backends 'company-jedi)
  )
  (add-hook 'python-mode-hook 'my/python-mode-hook)
  (add-hook 'python-mode-hook 'company-mode)
)
paaguti commented 1 year ago

It would be "nice" if this 'little detail' was somewhere in the documentation

best, /PA