打开 python 文件但正确设置 flake 时出现 Flymake 配置错误

Flymake config error while opening python file but correctly setup flake

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

Flymake: Configuration error has occured while running (flake8 >..../xyz_flymake.py). Flymake will be switched OFF.

但另一方面,我似乎已经配置了 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.

我该如何解决这个问题?

不清楚是什么配置错误。您可能 运行 遇到了众多问题之一。

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

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

    您可以通过 virtualenv ~/.elpy-venv 创建虚拟环境并使用 source ~/.elpy-venv/bin/activate 激活它。

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