Python as subprocess
Posted: Tue Mar 28, 2023 9:31 am
I am updating a no longer maintained plugin to Python 3 and having some issue with a section that runs a python script as a subprocess.
I can run the code in a normal method, but then the whole of indigo hangs when it tries to run whilst I have an edit device window open, so I am back to trying to make it run as a subprocess.
I have it running but it errors on when trying to import PIL, however import os and sys works, so it's specific to that package.
The code I am running is
and it errors on this
however running below in terminal works
(the bit in bold is copied from indigo logs where I print the params variable above.
I dont understand why python doesn't think that PILL is installed, when it runs standalone, and I have checked its installed with pip, pip3 and pip3.10 so not sure what version of python its trying to run this script under.
I can run the code in a normal method, but then the whole of indigo hangs when it tries to run whilst I have an edit device window open, so I am back to trying to make it run as a subprocess.
I have it running but it errors on when trying to import PIL, however import os and sys works, so it's specific to that package.
The code I am running is
- Code: Select all
imgResult = subprocess.run(['python3', pypath+'text2png.py', params], stdout=outputInfo, stderr=errorInfo)
and it errors on this
- Code: Select all
# Import the graphic conversion files
try:
import PIL
except:
print ('** PILLOW or PIL must be installed')
sys.exit(21)
however running below in terminal works
- Code: Select all
python3 text2png.py [b]/Users/simon/Documents/iTravel/WALWATtimetable.png /Users/simon/Documents/iTravel/WALWATdepartureBoard.txt /Users/simon/Documents/PycharmProjects/iTravel/iTravel.indigoPlugin/Contents/Server\ Plugin/trainparameters.txt YES[/b]
(the bit in bold is copied from indigo logs where I print the params variable above.
I dont understand why python doesn't think that PILL is installed, when it runs standalone, and I have checked its installed with pip, pip3 and pip3.10 so not sure what version of python its trying to run this script under.