Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1584

Python • Re: Subprocess Fails to Run

$
0
0
If I run 12345.py separately, it works as expected. Why does the LED not start blinking when 12345.py is run as a subprocess inside of barcodeTest1.py?
Are you running Bookwork and using Python's virtual environment (VENV)? If so, then you need to run the subproces so that it activates and runs inside of it.

Python has not done a lot of documentation on this. This simplest is to create a BASH file and run it. I found this example at https://bktapan.medium.com/how-to-sched ... bd6fcaa56a

Code:

#!/bin/bash# cd /home/mypc/awesomeproject# source venv/bin/activate# python myawesomepythonscript.py
The other is to execute a line that runs it in the virtual environment. I found the following here https://stackoverflow.com/questions/805 ... ith-python

Code:

import subprocess    cmd = 'source activate my_virtualenv; python my_script.py'subprocess.call(cmd, shell=True, executable='/bin/bash'))
I have not tried either and don't work with VENV's yet. Still on older OS's

Statistics: Posted by DS256 — Fri Nov 15, 2024 8:30 pm



Viewing all articles
Browse latest Browse all 1584

Trending Articles