4

I recently downloaded Emacs 25.2 with the dependencies on Windows 10. I'm attempting to run python script using elpy. I created an init file including -

(require 'package)
(add-to-list 'package-archives
         '("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(elpy-enable)

After failing, I also manually installed elpy - After running the first half of the init (above) ->

M-x package-refresh-contents RET
M-x package-install RET elpy RET
  1. It seems to have downloaded but I cannot access M-x elpy-config - Error message:

No such file or directory, python.

  1. Nor can I compile basic code -
print("Hello world")

Error message:

python HelloWorld.py 'python' is not recognized as an internal or external command, operable program or batch file.

Compilation exited abnormally with code 1

  1. When in the code it seems like none of the features elpy is supposed to have are working.

  2. I also cannot indent using tab in the script... I'm not sure if this is the same issue though.

I believe python is pre downloaded with emacs. Is this correct? Is there something I am missing in order to do this?

Thanks!

Edit: I realize having all of my init.el file may be necessary:

;; style
(menu-bar-mode 1)
(toggle-scroll-bar -1)
(tool-bar-mode 1)
(setq ring-bell-function 'ignore)
(customize-set-variable 'blink-cursor-mode nil)
(setq frame-title-format "")
(setq-default cursor-type 'vbar)

;; melpa
(require 'package)
(add-to-list 'package-archives
         '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

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

(defvar myPackages
  '(monokai-theme
    elpy
    flycheck
    better-defaults
    powerline))

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

(require 'powerline)

(cd "C:/My Documents")
(setq
   backup-by-copying t      ; don't clobber symlinks
   backup-directory-alist
    '(("." . "~/.saves/"))    ; don't litter my fs tree
   delete-old-versions t
   kept-new-versions 6
   kept-old-versions 2
   version-control t)       ; use versioned backups

(setq inhibit-startup-message t)

(elpy-enable)
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

(powerline-default-theme)
(load-theme 'monokai t)
(set-background-color "#2f343f")
(set-cursor-color "#A6E22E")
(set-face-attribute 'fringe nil    
            :background "#2f343f")

4

1 回答 1

4

我的环境变量路径中没有 python。

为了解决这个问题:

  • 打开windows搜索栏
  • 搜索环境变量
  • 路径 > 编辑... > 新建
  • 添加python文件的位置

另一种方法是重新打开安装程序,并确保在重新安装时选中添加到路径框。您可能需要卸载 python 才能执行第二种方式。

祝你好运!

于 2019-04-23T18:33:55.290 回答