4

当我在 emacs 中打开一个 python 文件时,我收到以下错误消息:

Flymake:运行时出现配置错误(flake8 >..../xyz_flymake.py)。Flymake 将关闭。

但另一方面,我似乎已经配置了 elpy 正常工作所需的所有模块:

Elpy Configuration

Virtualenv........: None
RPC Python........: 3.5.3 (/usr/bin/python3.5)
Interactive Python: /usr/bin/python3.5 (/usr/bin/python3.5)
Emacs.............: 24.5.1
Elpy..............: 1.10.0
Jedi..............: 0.10.2
Rope..............: 0.10.5
Importmagic.......: 0.1.7
Autopep8..........: 0.1.7
Syntax checker....: flake8 (/usr/local/bin/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.

Options

`Raised' text indicates buttons; type RET or click mouse-1 on a button
to invoke its action.  Invoke [+] to expand a group, and [-] to
collapse an expanded group.  Invoke the [Group], [Face], and [Option]
buttons below to edit that item in another window.

我该如何解决这个问题?

4

1 回答 1

4

不清楚配置错误是什么。您可能会遇到许多问题之一。

  1. 您似乎想使用 Python 3.5,但没有明确指示运行 Python Flake8 的版本。可能是 elpy 检测到不匹配并拒绝使用 Flake8,但它不会为您提供任何有用的信息。(Flake8 必须安装在与运行代码相同的 Python 版本上。)

  2. Elpy 似乎坚持要您使用 virtualenv 或添加~/.local/bin/到您的PATH. 我建议两者都做。

    您可以通过执行来创建一个 virtualenvvirtualenv ~/.elpy-venv并使用source ~/.elpy-venv/bin/activate.

    您可以编辑您的 Shell 的配置文件(例如 、、~/.bashrc等)来执行.~/.bash_profile~/.zshrcexport PATH="$PATH:~/.local/bin"

于 2017-07-10T12:35:20.100 回答