Introduction¶
This article demonstrates how to set up a Python virtual environment and how to use that virtual environment with Squish.
Squish 9.1 and newer¶
Linux¶
The steps below assume the following:
The user's home directory is "
/home/myuser
".The external Python installation Squish should use is (or is determined by) "
/usr/bin/python3.10
".The version of the external Python installation is 3.10.x.
The Python tool
pip3
is available in the external Python installation. (On Ubuntu it may be installed viasudo apt install python3-pip
.)
Respective values used below need to be adjusted to your specific setup.
Step 1 - Create Python Virtual Environment¶
In a shell/terminal execute:
python3.10 -m venv /home/myuser/venv
Step 2 - Configure Squish to use external Python Installation¶
Configure Squish to use the desired external Python installation via squishconfig :
In a shell/terminal execute:
cd "squish_dir"
./bin/squishconfig --python=/home/myuser/venv/bin/python
Step 3 - Configure Squish to use Virtual Environment¶
In the file squish_dir/etc/paths.ini
:
note current value of
PythonLDPath
find it in
LibraryPath
and replace with/home/myuser/venv/bin
replace
PythonLDPath
with/home/myuser/venv/bin
Step 4 - Start Squish IDE / squishrunner¶
Start Squish IDE / squishrunner with a specific PYTHONPATH (execute in a shell/terminal; use a shell script for convenience):
PYTHONPATH=/usr/lib/python3.10:/usr/lib/python3.10/lib-dynload:/home/myuser/venv/lib/python3.10/site-packages "squish_dir/squishide"
Windows¶
The steps below assume the following:
The user's home directory is "
C:\Users\myuser
".The external Python installation Squish should use is at "
C:\Program Files\Python310
".The version of the external Python installation is 3.10.x.
The Python tool
pip3
is available in the external Python installation. (On Ubuntu it may be installed viasudo apt install python3-pip
.)
Respective values used below need to be adjusted to your specific setup.
Step 1 - Create Python Virtual Environment¶
In cmd.exe/Command Prompt execute:
python3 -m venv C:\Users\myuser\tmp\venv
Step 2 - Configure Squish to use external Python Installation¶
Configure Squish to use the desired external Python installation via squishconfig :
In cmd.exe/Command Prompt execute:
cd "squish_dir"
bin\squishconfig.exe --python=C:\Users\myuser\tmp\venv\Scripts\python.exe
Step 3 - Start Squish IDE / squishrunner¶
Start Squish IDE / squishrunner with a specific PYTHONPATH (execute in cmd.exe/Command Prompt; for convenience create a .bat file):
set PYTHONPATH=C:\Program Files\Python310\Lib;C:\Program Files\Python310\DLLs;C:\Users\myuser\tmp\venv\Lib\site-packages
"squish_dir\squishide.exe"
Squish 9.0 and older¶
Linux¶
The steps below assume the following:
The user's home directory is "
/home/myuser
".The external Python installation Squish should use is (or is determined by) "
/usr/bin/python38
".The version of the external Python installation is 3.8.x.
The Python tool
pip3
is available in the external Python installation. (On Ubuntu it may be installed viasudo apt install python3-pip
.)The Python installation in the Squish package has the same major and minor version number (3.8) and architecture as the external Python installation.
Respective values used below need to be adjusted to your specific setup.
Step 1 - Install virtualenv module¶
In a shell/terminal execute:
sudo pip3 install virtualenv
Step 2 - Create Python Virtual Environment¶
In a shell/terminal execute:
virtualenv -p /usr/bin/python38 /home/myuser/venv
Step 3 - Configure Squish to use external Python Installation¶
Configure Squish to use the desired external Python installation via PythonChanger.py :
In a shell/terminal execute:
cd "squish_dir"
/usr/bin/python38 /home/myuser/Downloads/PythonChanger.py
Step 4 - Configure Squish to use Virtual Environment¶
In the file squish_dir/etc/paths.ini
change...
LibraryPath = "...:/usr/lib:..."
...to...
LibraryPath = "...:/home/myuser/venv/bin:..."
And also change...
Scripting/PythonHome = "/usr"
...to...
Scripting/PythonHome = "/home/myuser/venv"
Step 5 - Start Squish IDE / squishrunner¶
Start Squish IDE / squishrunner with a specific PYTHONPATH (execute in a shell/terminal execute; use a shell script for convenience):
PYTHONPATH=/usr/lib/python3.8:/usr/lib/python3.8/lib-dynload:/home/myuser/venv/lib/python3.8/site-packages "squish_dir/squishide"
Windows¶
The steps below assume the following:
The user's home directory is "
C:\Users\myuser
".The external Python installation Squish should use is at "
C:\Users\myuser\AppData\Local\Programs\Python
".The version of the external Python installation is 3.8.x.
The Python tool
pip3
is available in the external Python installation. (On Ubuntu it may be installed viasudo apt install python3-pip
.)The Python installation in the Squish package has the same major and minor version number (3.8) and architecture as the external Python installation.
Respective values used below need to be adjusted to your specific setup.
Step 1 - Install virtualenv module¶
In cmd.exe/Command Prompt execute:
pip install virtualenv
Step 2 - Create Python Virtual Environment¶
In cmd.exe/Command Prompt execute:
virtualenv.exe -p C:\Users\myuser\AppData\Local\Programs\Python\Python38\python.exe venv
Step 3 - Configure Squish to use external Python Installation¶
Configure Squish to use the desired external Python installation via PythonChanger.py :
In cmd.exe/Command Prompt execute:
cd "squish_dir"
C:\Users\myuser\AppData\Local\Programs\Python\Python38\python.exe C:\Users\myuser\Downloads\PythonChanger.py
Step 4 - Configure Squish to use Virtual Environment¶
In the file squish_dir/etc/paths.ini
change...
LibraryPath = "...:C:\Users\myuser\AppData\Local\Programs\Python\Python38:..."
...to...
LibraryPath = "...:C:\Users\myuser\tmp\venv\Scripts:..."
And also change...
Scripting/PythonHome = "C:\Users\myuser\AppData\Local\Programs\Python\Python38"
...to...
Scripting/PythonHome = "C:\Users\myuser\tmp\venv"
Step 5 - Start Squish IDE / squishrunner¶
Start Squish IDE / squishrunner with a specific PYTHONPATH (execute in cmd.exe/Command Prompt; for convenience create a .bat file):
set PYTHONPATH=C:\Users\myuser\AppData\Local\Programs\Python\Python38\Lib;C:\Users\myuser\AppData\Local\Programs\Python\Python38\DLLs;C:\Users\myuser\tmp\venv\Lib\site-packages
"squish_dir\squishide.exe"