首先,如果我的问题很愚蠢,请原谅。但是,我无法解决我遇到的问题。
我打算在 Python 上开始一个项目,并想使用 Emacs 作为默认编辑器。我想首先设置我的环境以便有效地工作。在以前的项目中,我使用现有环境,但想在本地机器上拥有自己的环境。我在 Mac OS 10.12.6 上。
我首先下载了 Python2.7.10 和最新的 Emacs——版本 26.1。我读到 Elpy 是 Python 最好的开发环境之一并下载了它。
这是我的.emacs文件。它位于我的主目录中(肯定不是最佳的)。
;; init.el --- Emacs configuration
;; INSTALL PACKAGES
;; --------------------------------------
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar myPackages
'(better-defaults
elpy ;; add elpy package
material-theme))
(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
;; init.el ends here
(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
(python-environment elpygen py-autopep8 material-theme elpy 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.
)
(elpy-enable)
在 Emacs 上,我想启用 Elpy。查看配置,我得到以下信息
Virtualenv........: None
RPC Python........: 2.7.10 (/usr/bin/python)
Interactive Python: python (/usr/bin/python)
Emacs.............: 26.1
Elpy..............: 1.24.0
Jedi..............: Not found
Rope..............: Not found
Autopep8..........: Not found
Yapf..............: Not found
Black.............: Not found
Syntax checker....: Not found (flake8)
...
The jedi package is not available. Completion and code navigation will
not work.
[run] easy_install --user jedi
...
我已经使用以下命令安装了 Jedi、Rope、...
pip install jedi, rope
通过单击“运行”,我收到以下消息:
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 7, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
我尝试了在这个问题中所做的事情: 没有名为 pkg_ressources 的模块。我更新了我当前版本的 pip、setuptools、distribute,......但没有任何效果。我是否应该删除所有内容并重新开始(如果不删除所有内容可能会很危险)?
我真的不知道从哪里开始。重新安装 setuptool 包并没有改变任何东西。
以前我安装了 Python3.x,也许它搞砸了安装。
任何帮助表示赞赏。
非常感谢。