在MacOS上的Emacs中设置PYTHONPATH?

时间:2021-11-18 12:07:22

Emacs does not recognize my correct Python path. I think it is a general problem with Emacs not recognizing my environment variables. I have GNU Emacs 22.1.1 (i386-apple-darwin8.9.1, Carbon Version 1.6.0) of 2007-06-17 installed.

Emacs无法识别我正确的Python路径。我认为这是Emacs无法识别我的环境变量的一般问题。我安装了2007-06-17的GNU Emacs 22.1.1(i386-apple-darwin8.9.1,Carbon Version 1.6.0)。

I have set PYTHONPATH in my ~/.bashrc. Maybe I should set it somewhere else?

我在〜/ .bashrc中设置了PYTHONPATH。也许我应该把它放在其他地方?

2 个解决方案

#1


22  

.bashrc only gets read when a shell starts; it won't affect Carbon Emacs. Instead, use setenv in your .emacs:

.bashrc只在shell启动时被读取;它不会影响Carbon Emacs。相反,在.emacs中使用setenv:

(setenv "PYTHONPATH" "PATH_STRING_HERE")

You can set PYTHONPATH for the entire Mac OS session, by adding it to ~/.MacOSX/environment.plist (more here). You probably don't want to do this unless you have XCode (and its property list editor) installed.

您可以将整个Mac OS会话设置为PYTHONPATH,方法是将其添加到〜/ .MacOSX / environment.plist(此处更多)。除非安装了XCode(及其属性列表编辑器),否则您可能不希望这样做。

(Via Procrastiblog)

#2


4  

In order not to manually copy paste:

为了不手动复制粘贴:

(setenv "PYTHONPATH" (shell-command-to-string "$SHELL --login -c 'echo -n $PYTHONPATH'"))

#1


22  

.bashrc only gets read when a shell starts; it won't affect Carbon Emacs. Instead, use setenv in your .emacs:

.bashrc只在shell启动时被读取;它不会影响Carbon Emacs。相反,在.emacs中使用setenv:

(setenv "PYTHONPATH" "PATH_STRING_HERE")

You can set PYTHONPATH for the entire Mac OS session, by adding it to ~/.MacOSX/environment.plist (more here). You probably don't want to do this unless you have XCode (and its property list editor) installed.

您可以将整个Mac OS会话设置为PYTHONPATH,方法是将其添加到〜/ .MacOSX / environment.plist(此处更多)。除非安装了XCode(及其属性列表编辑器),否则您可能不希望这样做。

(Via Procrastiblog)

#2


4  

In order not to manually copy paste:

为了不手动复制粘贴:

(setenv "PYTHONPATH" (shell-command-to-string "$SHELL --login -c 'echo -n $PYTHONPATH'"))