1

I have a following bash script:

script.sh

#!/bin/bash
echo "Ann"
echo "Kasia"
source /home/user/anaconda3/etc/profile.d/conda.sh
conda activate my_environment
conda list

I want to run it using QtCore.QProcess. I tested the following configurations, unfortunately non of them printed results.

main.py

from PyQt5 import  QtCore
process = QtCore.QProcess()
process.start("/bin/bash", ["-i", "-c", "script.sh"])

from PyQt5 import  QtCore
process = QtCore.QProcess()
process.start("script.sh")

The output is 'Process finished with exit code 0'

I expect it to be something like:

Ann
Kasia
wcwidth                   0.2.5                      py_0  
webencodings              0.5.1                    py38_1  
werkzeug                  1.0.1                      py_0  
wheel                     0.35.1                     py_0  
widgetsnbextension        3.5.1                    py38_0
1
  • I want to admit that when I open terminal and type ./script.sh it works fine and prints output Commented Nov 27, 2020 at 23:42

1 Answer 1

1

QProcess.start() starts a process asynchronously. That means you probably want to call waitForStarted() and/or waitForFinished() to ensure it finishes before you carry on.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.