# Creating a Virtual Environment for an Alternative Python Interpreter

If you want to create an SPK containing a different Python interpreter than the one distributed with Spotfire Service for Python, but you do not want to package it from within that Python interpreter, then you can create a virtual environment and create the SPK there.

## About this task

Important: You must build a package for the operating system on which your Spotfire Server node manager is installed. This procedure creates a package for an alternativePython interpreter from a Windows computer.

This procedure describes creating 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. If you want to install the "spotfire" package into your alternative Python installation, see Creating a Spotfire package for an alternative Python interpreter (for Windows).

Perform this task from the command prompt on the Windows computer where Spotfire is installed.

## 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. Create the new virtual environment.

       path/to/python/to/package/python -m venv %NEW_DIR%\venv

   Where `path/to/python/to/package/` is the path to the version of Python to include in the package.
2. Activate the virtual environment.

       %NEW_DIR%/venv/Scripts/activate.bat

   The command prompt changes to indicate that the virtual environment is active.
3. Install the 'spotfire' package into the virtual environment.

       path/to/virtual/env/ python -m pip install spotfire

4. To create the interpreter package, run the Python interpreter that you want to package.

       python -m spotfire.spk python [--analyst] name.spk

   The `--analyst` argument specifies that the package is to be distributed to installed Spotfire clients.
5. Deactivate the virtual environment.

       deactivate

   The command prompt reverts to the original prompt.

## Results

The package containing the Python interpreter to distribute can be found in the file name.spk

## What to do next

Place the SPK on the node manager for distribution to other Spotfire Analyst users.