Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set PYTHONPATH in Emacs on MacOS?

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.

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

like image 913
Roman Glass Avatar asked Oct 28 '08 12:10

Roman Glass


2 Answers

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

(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.

(Via Procrastiblog)

like image 168
Chris Conway Avatar answered Sep 17 '22 21:09

Chris Conway


In order not to manually copy paste:

(setenv "PYTHONPATH" (shell-command-to-string "$SHELL --login -c 'echo -n $PYTHONPATH'"))
like image 27
Christophe Van Neste Avatar answered Sep 19 '22 21:09

Christophe Van Neste