Python 3,Emacs中的Elpy(OSX):找不到完成用户错误:无法在点完成

时间:2018-04-24 01:15:25

标签: macos emacs python-3.5 elpy

OSX 10.13.4 emacs:25.3(9.0) python 3.5.2

我在emcas中遇到elpy自动完成问题。基本上,elpy卡在点上(例如:numpy.),并不表示任何可能的完成。如果我按任意键,我会看到一条消息:'未找到完成 用户错误:无法在点'#39;虽然所有必需的包装都已妥善安装。我怀疑这可能是由于配置:

Elpy Configuration

Virtualenv........: None
RPC Python........: 3.5.2 (/usr/local/bin/python3)
Interactive Python: /usr/local/bin/python3 (/usr/local/bin/python3)
Emacs.............: 25.3.1
Elpy..............: 1.19.0
Jedi..............: 0.12.0
Rope..............: 0.10.7
Autopep8..........: 1.3.5
Yapf..............: 0.21.0
Syntax checker....: Not found (flake8)

You have not activated a virtual env. While Elpy supports this, it is
often a good idea to work inside a virtual env. You can use M-x
pyvenv-activate or M-x pyvenv-workon to activate a virtual env.

The directory ~/.local/bin/ is not in your PATH. As there is no active
virtualenv, installing Python packages locally will place executables
in that directory, so Emacs won't find them. If you are missing some
commands, do add this directory to your PATH -- and then do
`elpy-rpc-restart'.

The configured syntax checker could not be found. Elpy uses this
program to provide syntax checks of your programs, so you might want
to install one. Elpy by default uses flake8.

但是,在尝试设置路径时:' PATH = $ PATH:/。local / bin /'在终端确实解决了问题。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

解决此问题的最简单方法是使用:https://github.com/purcell/exec-path-from-shell包。它将在Emacs中设置修复问题的路径。如果您不想安装此软件包,可以将以下代码段放在.emacs中。

(let ((path (shell-command-to-string "$SHELL -cl \"printf %s \\\"\\\$PATH\\\"\"")))
  (setenv "PATH" path)
  (setq exec-path (split-string path path-separator)))

以上内容适用于sh兼容的任何shell。我建议使用exec-path-from-shell很容易设置,并且无论你使用什么外壳都做正确的事。

请注意,这两种方法都会从shell中获取$PATH,因此请确保PATH已根据您的$HOME/.bashrc进行设置,并假设您已export PATH=$HOME/.local/bin:$PATH使用bash。类似于:import webbrowser urls = ["google.com", "yahoo.com", "bing.com", "duckduckgo.com"] firefox_path = "C:\\Program Files\\Mozilla Firefox\\firefox.exe" webbrowser.register('firefox', None, webbrowser.BackgroundBrowser(firefox_path), 1) for i in urls: webbrowser.get('firefox').open_new_tab(i) 应该这样做。