Skip to content

Commit

Permalink
Make sure ipython uses the correct executable. Refs #5987
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Oct 22, 2012
1 parent 73c200e commit 77161ab
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Code/Mantid/MantidPlot/ipython_plugin/internal_ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@
# Functions and classes
#-----------------------------------------------------------------------------

def get_executable():
"""Returns a string giving the executable to run when starting the IPython kernel
"""
# We have to make sure we can actually call the Python executable as this script will
# have probably been called from MantidPlot and in that instance MantidPlot will
# be the sys.executable file. Assume that Linux & OS X can just call Python but
# on Windows we will have to assume that python.exe is next to MantidPlot.exe
# but not necessarily in the PATH variable
import sys
if sys.platform == "win32":
import os
# pythonw avoids a new terminal window when the new process starts (only applicable
# on the packaged build
return os.path.join(sys.exec_prefix, "pythonw.exe")
else:
return "python"

def pylab_kernel(gui):
"""Launch and return an IPython kernel with pylab support for the desired gui
"""
kernel = IPKernelApp.instance()
# Note: pylab command seems to be needed for event loop to behave nicely
kernel.initialize(['python', '--pylab=%s' % gui,
"--c='%run -m mantidplotrc'"])
kernel.initialize([get_executable(), '--pylab=%s' % gui,
"--c='%run -m mantidplotrc'"])

return kernel


Expand Down Expand Up @@ -58,7 +76,7 @@ def new_qt_console(self, evt=None):
"qtconsoleapp.main()"
])
from subprocess import Popen, PIPE
return Popen([sys.exec_prefix+'\pythonw.exe', '-c', cmd, '--existing', cf] + argv, stdout=PIPE, stderr=PIPE)
return Popen([get_executable(), '-c', cmd, '--existing', cf] + argv, stdout=PIPE, stderr=PIPE)

return connect_qtconsole()

Expand Down

0 comments on commit 77161ab

Please sign in to comment.