几个月前,我已经安装了emacs-jedi,它运行得很好。过了一段时间,没有python项目,我回来了(更新了emacs 26并重新安装了emacs-jedi),我遇到了问题:
当我刚启动emacs时,jedi正常工作。但是,一旦我运行M-x pyvenv-workon some_python3_venv
,jedi就会停止工作。我得到了可怕的错误(当然,我也尝试jedi:install-server
):
Error (jedi):
================================
Failed to start Jedi EPC server.
================================
*** EPC Error ***
Server may raise an error. Use "M-x epc:pop-to-last-server-process-buffer RET" to see full traceback:
No handlers could be found for logger "jediepcserver"
*** EPC Server Output (last 10 lines) ***
No handlers could be found for logger "jediepcserver"
*** EPC Server Config ***
Server arguments: ("/home/me/.emacs.d/.python-environments/default/bin/jediepcserver" "--virtual-env" "/home/me/.virtualenvs/some_project")
Actual command: /home/me/.emacs.d/.python-environments/default/bin/jediepcserver
VIRTUAL_ENV envvar: "/home/me/.virtualenvs/some_project"
*** jedi-mode is disabled in #<buffer algorithms.py> ***
Fix the problem and re-enable it.
*** You may need to run "M-x jedi:install-server". ***
This could solve the problem especially if you haven't run the command yet
since Jedi.el installation or update and if the server complains about
Python module imports.
在“重新开始后的良好情况”中,jedi:show-setup-info
告诉我:
;; Emacs Lisp version:
(:emacs-version "26.1" :jedi-version "0.2.7" :python-environment-version "0.0.2alpha0")
;; Python version:
((:version "2.7.16 (default, Apr 6 2019, 01:42:57) \n[GCC 8.3.0]" :name "sys" :file nil)
(:version "0.13.3" :name "jedi" :file "/home/me/.emacs.d/.python-environments/default/local/lib/python2.7/site-packages/jedi/__init__.pyc")
(:version "0.0.5" :name "epc" :file "/home/me/.emacs.d/.python-environments/default/local/lib/python2.7/site-packages/epc/__init__.pyc")
(:version "0.0.3" :name "sexpdata" :file "/home/me/.emacs.d/.python-environments/default/local/lib/python2.7/site-packages/sexpdata.pyc"))
;; Command line:
(:virtualenv "/usr/bin/virtualenv" :virtualenv-version "15.1.0\n")
;; Customization:
((jedi:complete-on-dot)
(jedi:doc-display-buffer . display-buffer)
(jedi:doc-hook view-mode)
(jedi:doc-mode . rst-mode)
(jedi:environment-root)
(jedi:environment-virtualenv)
(jedi:get-in-function-call-delay . 1000)
(jedi:get-in-function-call-timeout . 3000)
(jedi:goto-definition-config
(nil nil nil)
(t nil nil)
(nil definition nil)
(t definition nil)
(nil nil t)
(t nil t)
(nil definition t)
(t definition t))
(jedi:goto-definition-marker-ring-length . 16)
(jedi:imenu-create-index-function . jedi:create-nested-imenu-index)
(jedi:import-python-el-settings . t)
(jedi:install-imenu)
(jedi:install-python-jedi-dev-command "pip" "install" "--upgrade" "git+https://github.com/davidhalter/jedi.git@master#egg=jedi")
(jedi:key-complete .
[C-tab])
(jedi:key-goto-definition .
[67108910])
(jedi:key-goto-definition-pop-marker .
[67108908])
(jedi:key-related-names . "r")
(jedi:key-show-doc . "d")
(jedi:server-args)
(jedi:server-command "/home/me/.emacs.d/.python-environments/default/bin/jediepcserver")
(jedi:setup-keys)
(jedi:tooltip-method)
(jedi:use-shortcuts)
(python-environment-default-root-name . "default")
(python-environment-directory . "~/.emacs.d/.python-environments")
(python-environment-virtualenv "virtualenv" "--system-site-packages" "--quiet"))
运行M-x pyvenv-workon
之后,我得到的输出几乎相同,但是;; Python version:
部分显示了一些错误:
;; Emacs Lisp version:
(:emacs-version "26.1" :jedi-version "0.2.7" :python-environment-version "0.0.2alpha0")
;; Python version:
nil
;; EPC error:
(:get-epc-error
(wrong-type-argument epc:manager nil))
要与我的项目所需的virtualenv一起运行emacs-jedi,我该怎么做?我尝试自定义jedi:server-args
,但这无济于事。