\(\renewcommand\AA{\unicode{x212B}}\)
MantidPython can be used to access all of the functionality of the Mantid Framework outside of the Workbench interface.
The Jupyter Notebook is a web-based interactive computational environment where you can combine code execution, text, mathematics, plots and rich media into a single document.
Open a Command Prompt.
Launch MantidPython:
C:\MantidInstall\bin\mantidpython.bat --classic
Launch Jupyter Notebook:
C:\MantidInstall\bin\mantidpython.bat notebook
Open Terminal.
Launch MantidPython:
/Applications/MantidWorkbench.app/Contents/MacOS/mantidpython --classic
Launch Jupyter Notebook:
/Applications/MantidWorkbench.app/Contents/MacOS/mantidpython notebook
Open Terminal.
Launch MantidPython:
/opt/Mantid/bin/mantidpython --classic
Launch Jupyter Notebook:
/opt/Mantid/bin/mantidpython notebook --notebook-dir="~"
In MantidPython or an Jupyter Notebook, accessing the Mantid Framework should be as simple as:
from mantid.simpleapi import *
If this doesn’t work, the path to the Mantid Installation directory should be set:
import sys
sys.path.append('PATH')
Where the ‘PATH’ should be:
[INSTALL_PATH]\bin
where INSTALL_PATH
eg. 'C:\MantidInstall\bin\'
/opt/Mantid/bin:/opt/Mantid/lib
for an official release and /opt/mantidnightly/bin:/opt/mantidnightly/lib
for a nightly development build/Applications/MantidWorkbench.app/Contents/MacOS
Simply call the script after the MantidPython or Notebook launch command:
Run a python script on MacOS:
/Applications/MantidWorkbench.app/Contents/MacOS/mantidpython --classic script.py
Run a notebook on Windows:
C:\MantidInstall\bin\mantidpython.bat notebook "Downloads\Introduction to using Mantid with IPython Notebook.ipynb"
After processing a workspace in Mantid, the history of how this data was manipulated can be converted to a script or a notebook, with the use of GeneratePythonScript v1 or GenerateIPythonNotebook v1 respectively.
Category: Concepts