无法保存文件:"autopep8 command not found"

Can't save file: "autopep8 command not found"

我在 emacs 中 运行 python。我已经写了一些代码,现在我像往常一样使用 C-x C-s 来保存代码。但是,autopep8 command not found 没有保存,而是出现在迷你缓冲区中。我无法保存我的代码。

如何恢复 emacs 的功能并保存我的文件?

这是我的 init.el

;; init.el --- Emacs configuration

;; INSTALL PACKAGES
;; --------------------------------------

(require 'package)

(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))

(package-initialize)
(when (not package-archive-contents)
  (package-refresh-contents))

(defvar myPackages
  '(better-defaults
    paredit
    idle-highlight-mode
    ido-ubiquitous
    find-file-in-project
    smex
    scpaste
    ein
    elpy
    flycheck
    material-theme
    py-autopep8))
(package-refresh-contents)

(mapc #'(lambda (package)
    (unless (package-installed-p package)
      (package-install package)))
      myPackages)

;; BASIC CUSTOMIZATION
;; --------------------------------------

(setq inhibit-startup-message t) ;; hide the startup message
(load-theme 'material t) ;; load material theme
(global-linum-mode t) ;; enable line numbers globally

;; PYTHON CONFIGURATION
;; --------------------------------------

(elpy-enable)
(elpy-use-ipython)

;; use flycheck not flymake with elpy
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)

;; init.el ends here

安装提供命令 autopep8 的软件包或删除行

;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)

来自您的配置。可以使用 pip 或您的包管理器完成安装,具体取决于您的系统。在 Ubuntu,这将是

sudo apt-get install python-autopep8

pip install autopep8