ipython/ipython — Issue #1044: run -p doesn't work in python 3
Author: Gitusername
Created: 2011-11-25 11:51:22+00:00
State: open

In python 3.2.2 and ipython 0.11, I can't get `run -p` to work - as far as I can see, this is because of the use of `execfile` which was removed in python 3 (it doesn't look like this has been fixed in the development version, but I haven't tried it).

```python
In [11]: run -p test
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/.../test.py in ()
----> 1 get_ipython().magic("run -p plots")

/usr/local/lib/python3.2/dist-packages/IPython/core/interactiveshell.py in magic(self, arg_s, next_input)
1869 self._magic_locals = sys._getframe(1).f_locals
1870 with self.builtin_trap:
-> 1871 result = fn(magic_args)
1872 # Ensure we're not keeping object references around:

1873 self._magic_locals = {}

/usr/local/lib/python3.2/dist-packages/IPython/core/magic.py in magic_run(self, parameter_s, runner, file_finder)
1617 with self.readline_no_record:
1618 if 'p' in opts:
-> 1619 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1620 else:
1621 if 'd' in opts:

/usr/local/lib/python3.2/dist-packages/IPython/core/magic.py in magic_prun(self, parameter_s, user_mode, opts, arg_lst, prog_ns)
1377 prof = profile.Profile()
1378 try:
-> 1379 prof = prof.runctx(arg_str,namespace,namespace)
1380 sys_exit = ''
1381 except SystemExit:

/usr/lib/python3.2/cProfile.py in runctx(self, cmd, globals, locals)
133 self.enable()
134 try:
--> 135 exec(cmd, globals, locals)
136 finally:
137 self.disable()

/.../ in ()

NameError: name 'execfile' is not defined
```