# Creating a Spotfire package for an alternative Python interpreter (for Windows)

The installation of the Spotfire Service for Python on your Spotfire Server includes a Python interpreter and a set of packages to enable using Python. The installed Spotfire client that connects to the Spotfire Server also includes the same version of a Python interpreter. You can provide a different version of the Python interpreter, if needed, on both the Spotfire Server and installed Spotfire clients.

## About this task

To install an alternative version of the Python interpreter on both the Spotfire Server and in the installed Spotfire client, create a Spotfire package (SPK) containing the Python interpreter for each of the installations, and then upload the SPKs to the Spotfire Server.
Note: Remember that the same version of the Python interpreter must run on both the Spotfire Server and the computers running Spotfire clients that connect to it.

Perform this task on a Windows computer where the Python interpreter that you want to distribute is installed.

Building an SPK on a Windows computer creates an SPK that works only on a Spotfire Server node manager installed on a Windows server. If you are running a Spotfire Server node manager on a Linux server, see Build a suitable Python interpreter for Spotfire Service for Python (for Linux)

This procedure describes installing the 'spotfire' package into the Python interpreter that you want to distribute. Alternatively, you can create a virtual environment to keep your installation of Python pristine, in the case where you either do not want to (or cannot) install the 'spotfire' package into the Python interpreter. See Creating a Virtual Environment for an Alternative Python Interpreter for those instructions.

## Before you begin

Before you begin, complete the following tasks.

1. Download and install a suitable 64-bit Python interpreter. Python 3.9 or higher is required. Make sure it is configured to work correctly with your system. (The steps in this task demonstrate building the Python interpreter using Python version 3.12.9.)
2. Locate and download Spotfire® Statistics Services for your operating system on the product download site Spotfire Download site (license and account required). The product Spotfire® Statistics Services includes the Spotfire Service for Python.
3. In the Spotfire Statistics Services downloaded bundle, find the component Spotfire Service for Python.
4. Extract the contents of the Spotfire Service for Python installation archive.

## Procedure

1. Install the 'spotfire' package into your Python interpreter.

       path/to/python/to/package/ python -m pip install spotfire

   `Where path/to/python/to/package` is the path to the Python interpreter to include in the package.
   Note: This also downloads and installs the other packages required by the Spotfire Service for Python.
2. Build the Python interpreter SPK for the Spotfire Server.

       path/to/python/to/package/python -m spotfire.spk python name1.spk

   This command creates an SPK to install the Spotfire Service for Python on the node manager. See the table in Step 3 for more information about the options.
   Tip: Provide a meaningful name for the .spk file so you can find it easily and distinguish it from the one you create in Step 3.
3. Build the Python interpreter SPK for the installed Spotfire clients.

       path/to/python/to/package/python -m spotfire.spk python --analyst name2.spk

   Tip: Provide a meaningful name for the .spk file so you can find it easily and distinguish it from the one you create in Step 2.

   Option | Description
   --- | ---
   `spotfire.spk` | The package containing the Python code to download and bundle the Python interpreter. Tip: From the command prompt, you can view help for the spotfire package by typing the following command:
       "<path-to-python-interpreter>\python\python.exe"
        -m spotfire.spk packages --help
   `python` | Specifies that the SPK contains the Python interpreter from which you issued the command.
   `--analyst` | Specifies that the Spotfire Server should distribute the Python interpreter in the SPK to other installed Spotfire clients connected to the Spotfire Server.
   `nameX.spk` | The name of the SPK file that is created by this task.
   `--constraints` | Optional. Constrains the required package versions to those listed in the file interpreter-constraints.txt, which is included with your distribution of Spotfire Service for Python. Provide the complete path to the file. For example:
       --constraints C:/files/interpreter-constraint.txt
   Important: If you omit this option, the required packages included might be updated to versions newer than the ones included with the Spotfire Service for Python. The included package versions are tested with Spotfire. While typically Python package authors take care for backwards compatibility, it is possible that a change to one of these packages could result in your data functions failing to work correctly. Spotfire Support can help you if you encounter such a breaking issue. See Included packages for more information.

## Results

The packages containing the Python interpreter to upload to the Spotfire Server can be found in the .spk files that you created.

## What to do next

Add the SPKs to the Spotfire Server Deployment area, and then validate and save the area. See Adding Software Packages to a Deployment Area and Updating Services in the Spotfire® Server Installation and Administration guide for more information. The next time the installed Spotfire client user connects to the Spotfire Server, they are prompted to update their installations with the new Python Interpreter and packages.