2

The default python version on mac osx snow leopard is python 2.6.1. I am learning python 3, so I have to change the interpreter. I have changed the setting in preference, so that it points to /Library/framework/python.framework/version/3.2/bin/python3.2. I believe that is where my 3.2 interpreter is installed. When I restart Emacs, everything works fine. When I start the interpreter, it says python 3.2:

Python 3.2 (r32:88452, Feb 20 2011, 11:12:31) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

However, when I ask Emacs to execute a buffer, this message shows up:

execfile(r'/var/folders/yV/yVXYrzONGSaZeoBmB-mdkE+++TI/-Tmp-/python-2180L5f.py') # PYTHON-MODE
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'execfile' is not defined

I don't know how to fix it. It has nothing to do with my code though, because this message shows up even when I try to execute:

print ("Hello World")
legoscia
  • 39,593
  • 22
  • 116
  • 167
Lii
  • 21
  • 2

2 Answers2

0

This is a longer answer, as I had to look into it.

  1. Python 3 will need to be installed on your system. I already installed HomeBrew, so this involved $ brew install python3. You can install with other methods as well.

  2. I use a virtualenv for Python 3. I make a virtualenv by using the virtualenv -P python3 myproj Aquamacs lets you M-x virtualenv-activate to set it.

  3. There were problems in the python-mode.el file, a lisp file hiding down in your /Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/edit-modes/python-mode. Andreas Roehler patched the bug. If the main python-mode page is still on version 6.1.2, you download a new python-mode.el here and copy it over your existing version.

Now it should work.

Charles Merriam
  • 19,908
  • 6
  • 73
  • 83
0

Python 3 does not have execfile(), so your emacs simply doesn't support Python 3.

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251