diff --git a/IPython/zmq/entry_point.py b/IPython/zmq/entry_point.py index f2e206e..c290364 100644 --- a/IPython/zmq/entry_point.py +++ b/IPython/zmq/entry_point.py @@ -155,7 +155,7 @@ def make_default_main(kernel_factory): def base_launch_kernel(code, xrep_port=0, pub_port=0, req_port=0, hb_port=0, - independent=False, extra_arguments=[]): + executable=None, independent=False, extra_arguments=[]): """ Launches a localhost kernel, binding to the specified ports. Parameters @@ -175,6 +175,9 @@ def base_launch_kernel(code, xrep_port=0, pub_port=0, req_port=0, hb_port=0, hb_port : int, optional The port to use for the hearbeat REP channel. + executable : str, optional (default sys.executable) + The Python executable to use for the kernel process. + independent : bool, optional (default False) If set, the kernel process is guaranteed to survive if this process dies. If not set, an effort is made to ensure that the kernel is killed @@ -212,7 +215,9 @@ def base_launch_kernel(code, xrep_port=0, pub_port=0, req_port=0, hb_port=0, hb_port = ports.pop(0) # Build the kernel launch command. - arguments = [ sys.executable, '-c', code, '--xrep', str(xrep_port), + if executable is None: + executable = sys.executable + arguments = [ executable, '-c', code, '--xrep', str(xrep_port), '--pub', str(pub_port), '--req', str(req_port), '--hb', str(hb_port) ] arguments.extend(extra_arguments) diff --git a/IPython/zmq/ipkernel.py b/IPython/zmq/ipkernel.py index e7ea87f..39013a1 100755 --- a/IPython/zmq/ipkernel.py +++ b/IPython/zmq/ipkernel.py @@ -551,7 +551,7 @@ class GTKKernel(Kernel): #----------------------------------------------------------------------------- def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0, - independent=False, pylab=False, colors=None): + executable=None, independent=False, pylab=False, colors=None): """Launches a localhost kernel, binding to the specified ports. Parameters @@ -571,6 +571,9 @@ def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0, hb_port : int, optional The port to use for the hearbeat REP channel. + executable : str, optional (default sys.executable) + The Python executable to use for the kernel process. + independent : bool, optional (default False) If set, the kernel process is guaranteed to survive if this process dies. If not set, an effort is made to ensure that the kernel is killed @@ -605,7 +608,7 @@ def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0, extra_arguments.append(colors) return base_launch_kernel('from IPython.zmq.ipkernel import main; main()', xrep_port, pub_port, req_port, hb_port, - independent, extra_arguments) + executable, independent, extra_arguments) def main(): diff --git a/IPython/zmq/pykernel.py b/IPython/zmq/pykernel.py index 8657add..b48e99d 100755 --- a/IPython/zmq/pykernel.py +++ b/IPython/zmq/pykernel.py @@ -248,7 +248,7 @@ class Kernel(HasTraits): #----------------------------------------------------------------------------- def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0, - independent=False): + executable=None, independent=False): """ Launches a localhost kernel, binding to the specified ports. Parameters @@ -268,6 +268,9 @@ def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0, hb_port : int, optional The port to use for the hearbeat REP channel. + executable : str, optional (default sys.executable) + The Python executable to use for the kernel process. + independent : bool, optional (default False) If set, the kernel process is guaranteed to survive if this process dies. If not set, an effort is made to ensure that the kernel is killed @@ -288,7 +291,8 @@ def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0, return base_launch_kernel('from IPython.zmq.pykernel import main; main()', xrep_port, pub_port, req_port, hb_port, - independent, extra_arguments=extra_arguments) + executable, independent, + extra_arguments=extra_arguments) main = make_default_main(Kernel)