Virtual Environment

To mitigate against conflicting dependencies, each tool created with the Python SDK can have an independent Python virtual environment. This allows tools to independently manage a list of dependencies, removing the need to consider other Python SDK tools that could be installed on a user's system.

Shared libraries

Each virtual environment has a Python binary, allowing environment creation with multiple Python versions, and can have independent Python packages installed in its site directories. The environment still shares the standard library with the base-installed Python.

By default, a virtual environment is isolated from system-level site-packages directories.

Virtual environment creation

A virtual environment can be created before or after a Python SDK tool is developed. If a tool does not use additional third-party Python libraries, a virtual environment is not needed.

The following steps detail the recommended process for installing a virtual environment. Consistent installation methods prevent issues with virtual environment replication for end users.

  1. Create a folder to hold the tool for either admin or non-admin access.
  2. Use a command prompt to run the command python -m venv <path name>. Execute the command from the Python install location.
  3. C:\Program Files\Alteryx\bin\Miniconda3>python -m venv C:\ProgramData\Alteryx\Tools\ExamplePythonSDKTool

    For more information about Python virtual environments, refer to Python3 documentation.

  4. Verify that a Python virtual environment is installed in the specified folder.

Additional 3rd party library installation

Use the following steps to install each third-party dependency required by your tool.

  1. Use a command prompt to access the Scripts folder, located in the installed virtual environment path of your tool.
  2. C:\ProgramData\Alteryx\Tools\ExamplePythonSDKTool\Scripts

  3. Use the pip installer to install an additional library.
  4. C:\ProgramData\Alteryx\Tools\ExamplePythonSDKTool\Scripts>pip install numpy

  5. Verify that the library is available in the virtual environment path.

Best practices

Test and manage a virtual environment for development and distribution, ensuring compatibility and portability, by adhering to the following standards.