Проблемы с получением elpy для работы с Emacs на OSX - PullRequest
0 голосов
/ 18 апреля 2020

Я следовал этому уроку здесь: https://realpython.com/emacs-the-best-python-editor/

В целом, у меня все настроено до части i python, где я набрал бы ctrl- c + ctrl- c для вызова i python.

Я получаю следующее:

-UU-:----F1  linter.py      All L1     (Python || Flymake[1 0]     Elpy) -----------
1Python 3.7.3 (default, Apr  7 2020, 14:06:47)
2[Clang 11.0.3 (clang-1103.0.32.59)] on darwin
3Type "help", "copyright", "credits" or "license" for more   information.
4>>> def lint(program):
5...     for i in program:
6...         print(i)
7...
8... lint("(var x = {y: [1,2,3] } )")
 import sys, codecs, os, ast;__pyfile = codecs.open('''/var/folders/y5/cthvczv9\
 1jzfb60c4tb0rn9h0000gn/T/py8GzCCN''', encoding='''utf-8''');__code = __pyfile.\
 read().encode('''utf-8''');__pyfile.close();os.remove('''/var/folders/y5/cthvc\
 zv91jzfb60c4tb0rn9h0000gn/T/py8GzCCN''');__block = ast.parse(__code, '''/Users\
 /sk/Research/data_structures_and_algorithms/linter.py''', mode='exec'); __bloc\
 k.body = (__block.body if not isinstance(__block.body[0], ast.If) else __block\
 .body if not isinstance(__block.body[0].test, ast.Name) else __block.body if n\
 ot __block.body[0].test.id == 'True' else __block.body[0].body) if sys.version\
 _info[0] < 3 else (__block.body if not isinstance(__block.body[0], ast.If) els\
 e __block.body if not isinstance(__block.body[0].test, ast.NameConstant) else \
 __block.body if not __block.body[0].test.value is True else __block.body[0].bo\
 dy);__last = __block.body[-1];__isexpr = isinstance(__last,ast.Expr);_ = __blo\
 ck.body.pop() if __isexpr else None;exec(compile(__block, '''/Users/sk/Researc\
 h/data_str

Вы видите все «jibberi sh», и я не могу выполнить скрипт.

Я работаю в виртуальной среде и мой elpy-config выглядит следующим образом:

 1Elpy Configuration
 2
 3Emacs.............: 26.3
 4Elpy..............: 1.33.0
 5Virtualenv........: venv (/Users/sk/Research/data_structures_and_algorithms/v\
  env)
 6Interactive Python: python 3.7.3 (/Users/sk/Research/data_structures_and_algo\
  rithms/venv/bin/python)
 7RPC virtualenv....: rpc-venv (/Users/sk/.emacs.d/elpy/rpc-venv)
 8 Python...........: python 3.7.3 (/Users/sk/.emacs.d/elpy/rpc-venv/bin/python\
  )
 9 Jedi.............: 0.17.0
10 Rope.............: 0.16.0
11 Autopep8.........: 1.5.1
12 Yapf.............: 0.29.0
13 Black............: 19.10b0
14Syntax checker....: flake8 (/Users/sk/Research/data_structures_and_algorithms\
  /venv/bin/flake8)
15
16Warnings

И, наконец, мой .emacs выглядит так:

;; .emacs

;; ===================================
;; MELPA Package Support
;; ===================================
;; Enables basic packaging support
(require 'package)

;; Adds the Melpa archive to the list of available repositories
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)

;; Initializes the package infrastructure
(package-initialize)

;; If there are no archived package contents, refresh them
(when (not package-archive-contents)
  (package-refresh-contents))

;; Installs packages
;;
;; myPackages contains a list of package names
(defvar myPackages
  '(better-defaults                 ;; Set up some better Emacs defaults
    material-theme                  ;; Theme
    elpy                            ;; Emacs List Python Environment
    )
  )

;; Scans the list in myPackages
;; If the package listed is not already installed, install it

(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

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages (quote (material-theme better-defaults))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )


;; ===================================
;; Development Customization
;; ===================================
;; Enable elpy
(elpy-enable)
(add-hook 'after-init-hook 'global-company-mode)
(setq python-shell-completion-native-enable nil)

(setenv "PATH" (concat (getenv "PATH") ":/home/sk/.local/bin"))
(setq exec-path (append exec-path '("/home/sk/.local/bin")))

Спасибо, я бился головой об этом некоторое время.

...