在 Emacs 上配置 Anaconda | Linux 中国

2019 年 3 月 10 日 Linux中国
本文描述了如何在 Emacs 上配置 Anaconda。(LCTT 译注:Anaconda 自称“世界上最流行的 Python/R 的数据分析平台”)
-- Devji Chhanga

也许我所追求的究极 IDE 就是 Emacs[1] 了。我的目标是使 Emacs 成为一款全能的 Python IDE。本文描述了如何在 Emacs 上配置 Anaconda。(LCTT 译注:Anaconda 自称“世界上最流行的 Python/R 的数据分析平台”)

我的配置信息:

◈ OS:Trisquel 8.0
◈ Emacs:GNU Emacs 25.3.2

快捷键说明(参见完全指南[2]):

   
   
     
  1. C-x = Ctrl + x
  2. M-x = Alt + x
  3. RET = ENTER

1、下载并安装 Anaconda

1.1 下载

从这儿[3] 下载 Anaconda。你应该下载 Python 3.x 的版本,因为 Python 2 在 2020 年就不再支持了。你无需预先安装 Python 3.x。这个安装脚本会自动安装它。

1.2 安装

   
   
     
  1. cd ~/Downloads
  2. bash Anaconda3-2018.12-Linux-x86.sh

2、将 Anaconda 添加到 Emacs

2.1 将 MELPA 添加到 Emacs

我们需要用到 anaconda-mode 这个 Emacs 包。该包位于 MELPA 仓库中。Emacs25 需要手工添加该仓库。

◈  注意:点击本文查看如何将 MELPA 添加到 Emacs [4]

2.2 为 Emacs 安装 anaconda-mode 包

   
   
     
  1. M-x package-install RET
  2. anaconda-mode RET

2.3 为 Emacs 配置 anaconda-mode

   
   
     
  1. echo "(add-hook 'python-mode-hook 'anaconda-mode)" > ~/.emacs.d/init.el

3、在 Emacs 上通过 Anaconda 运行你第一个脚本

3.1 创建新 .py 文件

   
   
     
  1. C-x C-f
  2. HelloWorld.py RET

3.2 输入下面代码

   
   
     
  1. print ("Hello World from Emacs")

3.3 运行之

   
   
     
  1. C-c C-p
  2. C-c C-c

输出为:

   
   
     
  1. Python 3.7.1 (default, Dec 14 2018, 19:46:24)
  2. [GCC 7.3.0] :: Anaconda, Inc. on linux
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> python.el: native completion setup loaded
  5. >>> Hello World from Emacs
  6. >>>

我是受到 Codingquark[5] 的影响才开始使用 Emacs 的。

有任何错误和遗漏请在评论中写下。干杯!


via: https://idevji.com/configure-anaconda-on-emacs/

作者:Devji Chhanga[7] 选题:lujun9972 译者:lujun9972 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

登录查看更多
0

相关内容

Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑向下兼容。
【2020新书】实战R语言4,323页pdf
专知会员服务
98+阅读 · 2020年7月1日
一份简明有趣的Python学习教程,42页pdf
专知会员服务
76+阅读 · 2020年6月22日
【新书】Python编程基础,669页pdf
专知会员服务
186+阅读 · 2019年10月10日
用 Python 开发 Excel 宏脚本的神器
私募工场
26+阅读 · 2019年9月8日
通过Docker安装谷歌足球游戏环境
CreateAMind
11+阅读 · 2019年7月7日
Kali Linux 渗透测试:密码攻击
计算机与网络安全
15+阅读 · 2019年5月13日
支持多标签页的Windows终端:Fluent 终端
Python程序员
7+阅读 · 2019年4月15日
Python | Jupyter导出PDF,自定义脚本告别G安装包
程序人生
7+阅读 · 2018年7月17日
Python 杠上 Java、C/C++,赢面有几成?
CSDN
6+阅读 · 2018年4月12日
教你用Python来玩跳一跳
七月在线实验室
6+阅读 · 2018年1月2日
Arxiv
43+阅读 · 2019年12月20日
Arxiv
7+阅读 · 2018年6月1日
Arxiv
6+阅读 · 2018年2月26日
Arxiv
4+阅读 · 2018年1月29日
Arxiv
151+阅读 · 2017年8月1日
VIP会员
相关资讯
用 Python 开发 Excel 宏脚本的神器
私募工场
26+阅读 · 2019年9月8日
通过Docker安装谷歌足球游戏环境
CreateAMind
11+阅读 · 2019年7月7日
Kali Linux 渗透测试:密码攻击
计算机与网络安全
15+阅读 · 2019年5月13日
支持多标签页的Windows终端:Fluent 终端
Python程序员
7+阅读 · 2019年4月15日
Python | Jupyter导出PDF,自定义脚本告别G安装包
程序人生
7+阅读 · 2018年7月17日
Python 杠上 Java、C/C++,赢面有几成?
CSDN
6+阅读 · 2018年4月12日
教你用Python来玩跳一跳
七月在线实验室
6+阅读 · 2018年1月2日
Top
微信扫码咨询专知VIP会员