Installing Python to use with Minitab Statistical Software

Verify that your Python installation works with Minitab Statistical Software and run your first Python script using Minitab Statistical Software.

Minitab Statistical Software integrates with Python, a general-purpose programming language with applications in data science. To accomplish Python integration, Minitab, LLC provides the mtbpy module. With this custom module, you can create tables, graphs, messages, and notes in Python and display them in Minitab. Python integration offers the flexibility of custom Python code within Minitab's easy-to-use interface, and the results can be saved, stored, and shared in Minitab Project Files. After you install the mtbpy package, you're ready to run Python code from Minitab. If you have Python code that you want to access routinely, you can customize Minitab's interface to make the analysis more accessible through custom buttons or menus.

For more information on Minitab's Python module, including Python code examples, go to Python API Reference.

For more information on Python, consult the guidance available at www.python.org.

All the files referenced in this guide are available in this .ZIP file: python_guide_files.zip.

Requirements
  • Minitab Desktop 20.3 (64-bit) or later. To check your version of Minitab, choose Help > About Minitab.
  • Python 3.7 or later (64-bit).

Step 1: Install Python

Typically, the default installation of Python works with Minitab Statistical Software. Follow the directions for your operating system at Python's website.
Note

Install and run Python before you attempt to integrate Python with Minitab Statistical Software. For assistance with the installation of Python, please consult with your organization's technical support department. Minitab Technical Support cannot assist with the installation of Python.

Microsoft® Windows

On Python's website, click Downloads > Windows. On the page, Python Releases for Windows, scroll to the version of Python that you want to install. Download and run the version linked as either "Windows x86-64 executable installer" or "Windows x86-64 web-based installer".

In the installer, select the option to add Python to your PATH during installation. If Python is not in your PATH, add Python to your system environment variables. Otherwise, Minitab will not be able to find Python.
Note

If you are using Python through an Anaconda environment, go to Additional instructions for Anaconda environments.

Note

If you have already installed Python and running python in the Microsoft® Windows Command Prompt opens the Microsoft® Store, go to Frequently Asked Questions about using Python on Windows.

Step 2: Install mtbpy

To use Python with Minitab, install the mtbpy package. The mtbpy package gives you the capability to bring data from Minitab into Python and to return Python results to Minitab. To install the latest version via PIP, run the corresponding command for your operating system's terminal:
Microsoft® Windows
python -m pip install mtbpy
Note

If you have already installed Python and running python in the Microsoft® Windows Command Prompt opens the Microsoft® Store, go to Frequently Asked Questions about using Python on Windows.

After Python and the mtbpy package are installed, you can use the PYSC command to run Python from Minitab.

Step 3: Verify the installation with Minitab

Use the following steps to verify that Minitab can find Python and mtbpy.

Open Minitab

Run a test file

Use the following file to perform the steps in this section:
File Description
test.py A sample Python script used throughout this guide. For this section, you run the script without arguments. When the script runs successfully, the result is the message "Minitab successfully located your Python installation."
  1. Put test.py in Minitab's folder for Python scripts. The default folder location depends on your operating system. For more information, go to Default folders for Python files for Minitab.
  2. After you save the file, run the following command in the Command Line pane in Minitab:
    PYSC "test.py"
    Important

    If the Minitab Command Line is not visible, choose View > Command Line/History.

If Python successfully works with Minitab, you will see the following output in Minitab:

Python Script

These results are from external software.
Minitab successfully located your Python installation.

Default folders for Python files for Minitab

Typically, Python integration with Minitab works best when the files that you use are in the default folder location for Minitab files. If you do not specify a file path when you run Python from within Minitab, Minitab looks for your Python files in the default folder.

Microsoft® Windows

The default location is the "My Documents" folder.

In the Microsoft® Windows operating system, if your Python file is in the default folder and you receive the error "File not found:", check the default file location in your Minitab settings. To view or change the default file location in Minitab, choose File > Options > General > Default file location.