Reputation:
If I just try to run my python file via QProcess with 'python3' and the file path, the QProcess will not executre. After playing around with this on terminal, I have figured out that when the file is run it cannot load the appropriate modules found in my virtual environment. How can I make QProcess execute the file but first open up the virtual environment?
This does not work:
loop_process = QProcess()
loop_process.start("python3", ['/home/id/VirtPython/looper_testing_ver5_2.py'])
# Gives the module cannot load error
So I tried this (where I tried to activate my virtenv):
loop_process = QProcess()
loop_process.start(". /scratch/id/pipenv/VirtPython-4445xf/bin/activate", ['python3' '/home/id/VirtPython/looper_testing_ver5_2.py'])
and it still fails but i dont know the error.
Upvotes: 1
Views: 242
Reputation: 243945
You just have to use the virtualenv python:
loop_process = QProcess()
loop_process.start("/scratch/id/pipenv/VirtPython-4445xf/bin/python3", ['/home/id/VirtPython/looper_testing_ver5_2.py'])
Upvotes: 1