Setting Up a Python Virtual Environment with Squish

Setting Up a Python Virtual Environment with Squish

Python Virtual Environments are great tools for separating different Python configurations on the same machine. Configuring Squish to use a virtual environment gives you the freedom to install packages and make changes that aid your testing efforts without compromising your existing Python installation(s).

Here we will show you how to set up Squish to use a Python Virtual Environment for testing.

First, install Python (ver 3.3 or higher) to use the virtual environment functionality. For Squish to be working with your Python installation, it has to be compiled with the same version. This is done by either asking our support staff to prepare a binary Squish edition with that Python version or by compiling Squish from sources.

Quick note for the configuration flags to compile Squish with Python 3: 
$ <SQUISH_SOURCES>/configure … --disable-python --enable-python3

At this point, make sure that the environment variables (PATH, PYTHONPATH, PYTHONHOME) point towards the Python installation from which you are creating a virtual environment. Then you can execute:

$ pip install virtualenv
$ python -m venv <PYTHON_VENV_PATH>

After the virtual environment is created, configure Squish to use it by altering the paths.ini in <SQUISHDIR>/etc/.

In LibraryPath change @(SQUISH_PREFIX)/python to <PYTHON_VENV_PATH>/bin
(<PYTHON_VENV_PATH>/Scripts on Windows).
Set Scripting/PythonHome to "<PYTHON_VENV_PATH>".

There are more detailed instructions on how to change the Python installation of Squish here. Now you are good to go!


Leave a reply

电子邮件地址不会被公开。 必填项已用*标注