简体   繁体   English

加载了Exec-Path时,Emacs无法找到Python.exe(Windows 8.1)

[英]Emacs Unable to Find Python.exe When Exec-Path Loaded (Windows 8.1)

I've had quite a bit of success using Emacs with R and Org-mode, and was wanting to branch that out into Python as well. 我在R和Org模式下使用Emacs取得了很大的成功,并且想将其扩展到Python中。 I initially set up my environmental path (through Windows) and exec-path (through the .emacs file) to point to the folder containing my Python binary. 最初,我设置环境路径(通过Windows)和exec-path(通过.emacs文件)以指向包含我的Python二进制文件的文件夹。 Unfortunately, when I try to evaluate a command/start the interpreter in Python-Mode, I get the following error: 不幸的是,当我尝试评估命令/以Python模式启动解释器时,出现以下错误:

python-shell-calculate-exec-path: Wrong type argument: listp, "~/folder/foo"

where "~/folder/foo" was the last item on my exec-path list. 其中“〜/ folder / foo”是我的exec-path列表中的最后一项。 When I removed exec-path from my .emacs file, the inferior Python process loaded fine. 当我从.emacs文件中删除exec-path时,劣等的Python进程加载正常。 Obviously, this is not a real solution if I want to use anything else on the path. 显然,如果我想在路径上使用其他任何东西,这不是真正的解决方案。 I've tried to search for documentation of this problem, but was less than successful. 我试图搜索有关此问题的文档,但未成功。

I am using GNU Emacs 24.5.1 (x86_64-w64-mingw32) on a Windows 8.1 laptop (Lenovo, if that matters). 我在Windows 8.1笔记本电脑(联想,如果重要)上使用GNU Emacs 24.5.1(x86_64-w64-mingw32)。 The failing mode is the basic "Python" and not "Python-Mode" proper, which doesn't seem to want to load. 失败模式是基本的“ Python”模式,而不是“ Python模式”,它似乎不想加载。 The python executable is properly configured in my environmental variables setup (it works in Windows command prompt), and the inferior python process works only so long as I do not have my exec-path loaded. 在我的环境变量设置中正确配置了python可执行文件(它在Windows命令提示符下有效),并且仅当我没有加载exec-path时,下等python进程才有效。 The relevant code is: 相关代码为:

(setq exec-path (append exec-path ' "~/folder/foo"
                                  ' "~/folder/foo"))

It's a bit odd, but it seems that explicitly setting the exec-path in this way was what was causing the problem. 这有点奇怪,但是似乎以这种方式显式设置了exec-path才是导致问题的原因。 After a little bit of fiddling around with alternative means of setting the exec-path (to avoid the listp problem) I found that using: 在摆弄了设置exec-path的另一种方法(避免了listp问题)后,我发现使用:

(add-to-list 'load-path "~/folder/foo")
(add-to-list 'load-path "~/folder/foo")

instead of setq exec-path worked just fine in terms of letting me use my binaries and in letting me get to Python, too. 在让我使用我的二进制文件以及让我也使用Python方面,而不是setq exec-path很好用。 Solution is posted in case anyone else has a similar issue (students and self-taught users like myself especially). 如果有人遇到类似问题(特别是像我这样的学生和自学成才的用户),则发布解决方案。

Note: I did not add the location of my Python executable to my .emacs file in any way, just the environmental variable Path in Windows. 注意:我没有以任何方式将Python可执行文件的位置添加到.emacs文件中,只是在Windows中添加了环境变量Path。 This was sufficient for Emacs to find the executable. 这足以使Emacs查找可执行文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM