Emacs使用较旧的Python版本(2.3)作为默认的Python模式,我是否可以告诉Emacs使用我在主目录下安装的更新版本?
顺便说一句,我正在使用Red Hat发行版,没有root特权。
检查您想要调整的事物的 customize-group 是一个好习惯。只需执行:
M-x customize-group RET python RET
现在你有多个选项,其中一个应该很有趣:
Python Python Command
您可以在那里自定义并保存以供今后使用。
尝试将以下内容添加到您的~/.emacs
文件中:
(setq python-python-command "~/your/python/bin-dir/python")
Emacs运行的python命令通常是python
,因此您可以尝试简单的方法来更改您的路径:
export PATH=~/your/python/bin-dir:$PATH
python-python-command
是针对“loveshack python.el”的,这是旧版emacs附带的python模式。而在当前版本中,“Gallina python.el”则是默认的模式。请改用python-shell-interpreter
。https://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc2 - jpkottapython-python-command
是为旧版“loveshack python.el”而设计的。对于使用“gallina python.el”的最新版本Emacs,请使用变量python-shell-interpreter
。
(setq python-shell-interpreter "/path/to/python")
https://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc2
# -*- python-shell-interpreter: "python3" -*-
- Lester Cheung (
(python-mode . (
(python-shell-interpreter . "~/my_project/venv/bin/python")
(flycheck-checker . python-pylint)
(flycheck-python-pylint-executable . "~/myproject/venv/bin/python")
(flycheck-pylintrc . "~/my_project/.pylintrc")
)
)
)
在Windows 10上,我安装了两个版本的Python:
C:\ProgramData\chocolatey\bin
下C:\Program Files\Python36\
下Emacs 正在使用 v3.5,但我更喜欢它使用 v3.6。因此,我通过编辑我的环境变量来进行以下更正:
编辑系统环境变量
-> 环境变量...
系统变量
下,选择 Path
变量 -> 编辑...
-> 新建
上移
将新的文件路径放置在其他Python目录之上。C:\Program Files\Python36\
(v3.6目录),然后将其移动到C:\ProgramData\chocolatey\bin
(v3.5目录)之上。
python
切换为python3
,所有问题立即得到解决。同时还发现了打开 eldoc 的开关。谢谢! - PascalVKooten