TestStand's Python Adapter Configuration Shows Invalid Virtual Environment Path

Updated Nov 6, 2024

Reported In

Software

  • TestStand

Programming Language

  • Python

Issue Details

I would like to use my Python script in TestStand but when I am configuring TestStand's Python adapter, it shows the following warning:
Invalid virtual environment path. TestStand supports virtual environment created using 'virtualenv' or 'venv' tool. Make sure virtual environment directory can be found using TestStand search directory.

Solution

To use Python script in TestStand, ensure the Python script is in a virtual environment directory.

  1. Instructions below demonstrate an example on how to create a virtual environment directory using 'virtualenv' for add.py Python script located in Desktop's PyTs folder.
    1. Open Command Prompt and install virtualenv package by using the following command: 
      • pip install virtualenv
    2. Change command prompt directory to Desktop since PyTs folder is located at Desktop.
    3. Create virtual environment for PyTs folder by using the following command:
      • virtualenv PyTs
    4. For example, the command set below would move you into the directory containing the public desktop and then create a virtual environment at C:\Users\Public\Desktop\PyTs
      • cd C:\Users\Public\Desktop
      • virtualenv PyTs
  2. Instructions below demonstrate an example on how to create a virtual environment directory using 'venv' for add.py Python script located in Desktop's PyTs folder.
    1. 'venv' tool should be installed natively with Python. 
    2. Create virtual environment for PyTs folder by using the following code:
      • python -m venv /path/to/new/virtual/environment
    3. For example, the command below would create a virtual environment at C:\Users\Public\Desktop\PyTs
      • python -m venv C:\Users\Public\Desktop\PyTs 
  3. Once the virtual environment creation is done, reconfigure Python adapter by pointing Python virtual environment to the PyTs folder. Python script can now be used in TestStand without invalid virtual environment path error.

    Additional Information

    If Directory PyTs Not Found pop-out window shows up after perform Step 1.d or 2.c above, user is encouraged to select Add the directory you created to the list of search directories. This is to ensure TestStand able to locate the folder without any issue.

    • TestStand 2024 Q4 and later supports Virtual Environments created with venv or virtualenv tool. 
    • TestStand 2023 Q4 and earlier only supports Virtual Environments created with venv or virtualenv tool.

    For more information on Python Adapter configuration see this documentation link.