This is a technical how-to on installing external python modules on Stonebranch's UA (Universal Agent). Users utilizing the bundled UA python environment may require external modules not delivered with the UA python environment. In Windows, you may find that you see the following error when trying to use pip to install these modules:
“C:\Program Files\universal\python36\scripts\pip3 install requests”
pip fatal error in launcher: unable to create process using ‘”‘
This is because we install in the “C:\Program Files” location. In order to install the required python modules, you can run the following commands from a command prompt (replacing "requests" with the required module name):
If you would like your script to automatically install any modules if they are not present, you can use the following example code in your script.
For example, if your Universal Task requires the “requests” module, you can use the following python code to install requests automatically if it is not already installed:
# -- Import requests, if error then install requests
from pip import main as pipmain
from pip._internal import main as pipmain
This works for all platforms.
Did this guide help you learn something new? Feel free to share it with your colleagues.