Questions tagged [subprocess]

The Python subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. Use it to run a shell command or an executable in Python.

Filter by
Sorted by
Tagged with
0 votes
0 answers
14 views

Python Script Stopped Triggering OpenVPN Config Files

I've been scratching my head at this for a few days. The below code worked perfectly fine earlier in the week, but then stopped triggering the OpenVPN Config files it references. Leading the the ...
Eric Hood's user avatar
0 votes
0 answers
28 views

Python call from website is causing webpage to hang

I have spent a little time looking through the site, but ultimately wind up at the same place with code that stops functioning. I'm a coding novice and currently trying to learn HTML, PHP, python and ...
bassjuggler's user avatar
0 votes
0 answers
25 views

Unable to pass inputs to stdin of Python subprocess

Unable to pass inputs to stdin of subprocess. Terminal gets struck while waiting for input. How can I handle stdin properly? def run_command(command: str, out_callback, in_callback): process = ...
Divy X's user avatar
  • 33
0 votes
0 answers
6 views

UACbypass running command as Administrator and get output in Python

Is there any way to use uacbypass and run the command as Administrator also get the output in Python? Just run the command as Administrator without uac screen and get the output What I expect: run(CMD)...
vIIr's user avatar
  • 11
0 votes
0 answers
49 views

python subprocess getting error when trying to install requirements.txt

I am trying to develop an automate python scripts using python subprocess. I am using fastapi uvicorn server for build automatically djago project but got internal 500 server error fast api while ...
boyenec's user avatar
  • 1,439
0 votes
0 answers
30 views

Execute a Python script from another Python script with argparse input argument and extract an output

Given: child.py: import argparse import json parser = argparse.ArgumentParser(description='A sample script with argparse') parser.add_argument('--query', type=str, help='Query Phrase', default="...
doplano's user avatar
  • 909
0 votes
1 answer
15 views

Exports inside subprocess.check_output() do not take effect for other commands inside same subprocess

command="./foo/s.sh && echo $VAR_T" subprocess.check_output(command, shell=True) s.sh does export VAR_T='foo' but for some reason its not visible to the echo command right after.
DevF's user avatar
  • 11
0 votes
0 answers
37 views

Output of Popen.poll() is a long string

Recently I started to use Popen.poll() one of my simple Python programs in order to check if the process is finished before running the 2nd command which requires the 1st one to be finished. It looks ...
Rafayel Paremuzyan's user avatar
0 votes
1 answer
28 views

How can I run a Python subprocess command and prefix the output with a timestamp?

I have a Python script that runs some subprocess commands on a Unix machine. The commands are relatively arbitrary. One example would be docker build . which ends up looking like subprocess.Popen(['...
pseudodev's user avatar
0 votes
1 answer
49 views

Error running python3 using subprocess in eclipse/pydev

Running simple test python3 script in eclipse/pydev Debian 11: import subprocess import os subprocess.call(["python3", "-c", "print(123)"]) causes following error: ...
Andrey's user avatar
  • 21
1 vote
0 answers
12 views

How to capture the print of the subprocess while polling with subprocess.Popen

I'm creating a small gui under ubuntu which starts a subprocess and prints the log in a text box. In my function, it calls another program using subprocess.POpen and print the log of the subprocess in ...
Ames ISU's user avatar
  • 199
0 votes
1 answer
31 views

Python 3.11 subprocess is not ending on Windows

on Windows using Python 3.11 when I launch a subprocess it is almost as if the process is blocked from exiting itself. This same bit of code works perfectly fine on Linux and macOS def launch_game(...
Mysterious Ghost's user avatar
0 votes
1 answer
27 views

Terminate a subprocess in a python app using a button from the GUI of a program

So I am trying to do a program in python using customtkinter and I have to start a command using a button from the GUI I have created and once it is started i would like to terminate it using the stop ...
Albii's user avatar
  • 11
0 votes
2 answers
53 views

I want to trigger/run a py file from another py file and move to my rest of code, I have tried all of bellow functions but no one is working

import time import subprocess import os import runpy subprocess.run(['python', 'process_1.py'],) # subprocess.call(['python', 'process_1.py'],) # os.system('python process_1.py') # runpy.run_path(...
Hassan Zamir's user avatar
0 votes
0 answers
28 views

Why does subprocess.run() have unexpected behavior in try else block?

Trying to make a "to mp4" converter function using ffmpeg that is going to convert a file to mp4, delete the original file, and return True or False for specific conditions. But I get some ...
Nikita Savenkov's user avatar
-1 votes
0 answers
25 views

When to use sub processes in Bpmn 2.0?

When would you use sub processes in Bpmn 2.0? I know sub processes are processes that are part of a larger process. Is there a rule for how many steps can be included in a sub process? Can something ...
Susan Lee's user avatar
0 votes
0 answers
34 views

wandb error when running as a subprocess: ManagerConnectionRefusedError: Connection to wandb service failed since the process is not available

I’m having a problem when I try to run a subprocess (with Popen) in my python script that executes a bash command (slurm sbatch) on a different computing node. The error happens during wandb.init(): ...
schlaepf's user avatar
0 votes
0 answers
38 views

What python library should I use for scripting gdb?

Hi I have been attempting to use python library functions to invoke terminal gdb in terminal on a file and input in another file and then read output(segfault or exit code) for automated debugging. I ...
candpythonprogrammer's user avatar
0 votes
0 answers
29 views

Detect end of a subprocess from many

How can I detected that a subprocess was ending at the time, that the other process(es) are still running? I upload a short code below:, where the first process ends after 5 seconds and import ...
Eagle's user avatar
  • 3,394
0 votes
0 answers
40 views

Python subprocess to communicate with non GUI

I am trying to communicate with a non-GUI software through python. Basically, after starting the process I need to wait for a response and type certain commands in the terminal. However the following ...
Limmi's user avatar
  • 111
0 votes
0 answers
17 views

Usage of subprocess with cx_freeze

I wrote this litte script to extract public keys from .p12 files import os import pandas as pd import subprocess def extract_public_key_from_p12_and_match_password(excel_file_path, p12_folder, ...
Aukru's user avatar
  • 135
0 votes
1 answer
25 views

Getting requirements to build wheel ... error: subprocess-exited-with-error

I am trying to install Copernicus Marine Service client (CLI & Python) to download data. So, I follow the instructions on their website and used python -m pip install copernicus-marine-client but ...
Ameen Mohamed Bassam's user avatar
0 votes
1 answer
32 views

memory leak reading video frames to numpy array using ffmpeg as a python subprocess

I can stream videos frame by frame to an OpenGL Texture2D OK in python (pi3d module, example in pi3d_demos/VideoWalk.py) but I've noticed that it gradually leaks memory. Below is a stripped down ...
paddyg's user avatar
  • 2,183
-1 votes
0 answers
35 views

Trying to run commands in WSL using Python subprocess

I am using the command subprocess.Popen('start cmd /k; wsl.exe', shell=True) to use Python to open cmd and then launch WSL. I am then trying to run a series of commands in that WSL shell (namely cd ....
RafaelCM's user avatar
0 votes
0 answers
35 views

How do you pass an io-file-like StringIO object to a subprocess that expects a specific file as input

I am trying to pass a file-like StringIO object to a subprocess which expects a file "file.ly". Possible problems might be the file extension and expected apostrophes before and after the ...
Björn's user avatar
  • 1
1 vote
0 answers
33 views

Unable to print output in python using subprocess when running compiled c executable

I'm trying to build a python 3.9 script that is able to run a compiled c99 program executable and test the functionality. The c program consists of a simple while loop that runs until the exit value ...
AlphaCloud's user avatar
0 votes
0 answers
12 views

Unable to send the CTRL_BREAK_EVENT signal to the process in no console mode on windows (pythonw / pyinstaller)

We are starting a tool process using the subprocess.popen. To stop the tool we are sending ctrl+c signal so that the tool catches this & does the required clean up & report generation. It is ...
Siva Kranthi Kumar's user avatar
0 votes
0 answers
40 views

Can TQDM track the output of a subprocess? [duplicate]

As part of a long pipeline (all orchestrated in Python), I'm calling an external program using the subprocess module. This program takes a while to finish, so I'd like to show the user a nice progress ...
Draconis's user avatar
  • 3,269
0 votes
0 answers
14 views

'gsutil cp' resulted in empty file when in python subprocess piped command

The issue here is that the file copied in the first subprocess below is empty in the gs bucket. subprocess.call("/usr/bin/gsutil cat infile | grep '|N|' > filename | /usr/bin/gsutil cp ...
ddss12's user avatar
  • 99
0 votes
0 answers
22 views

Encountering NotImplementedError in Asynchronous Code with Playwright: Understanding the Cause and Seeking Solutions

I encountered a NotImplementedError when running my asynchronous code with Playwright. Could you help me understand the root cause of this error and suggest a possible solution? This is the code I ran:...
Fashola John's user avatar
0 votes
1 answer
94 views

How to use subprocess and PowerBI CMDlets within Python to keep terminal open to save more commands?

The Problem: Subprocess Terminal does not stay open and logs off Azure Service Account before letting me put in Azure Powershell Commands. Python Code import subprocess Login = subprocess.Popen(['...
On3moy's user avatar
  • 3
1 vote
1 answer
107 views

Is there any influence of the main process when launching a subprocess with subprocess.Popen?

I'm trying to find information about "side effects" of launching Windows process with the subprocess.Popen library of Python. I've heard that there are some good/bad practices for launching ...
stack92's user avatar
  • 11
0 votes
1 answer
42 views

get text from stdout in subprocess.run without UnicodeDecodeError

I read the output from a windows command line call like so: result = subprocess.run(["cmd", "/c", "dir","c:\mypath"], stdout=subprocess.PIPE, text=True,check=...
Fred's user avatar
  • 451
0 votes
0 answers
23 views

No module in called subprocess (library "subprocess" can't call a py-file with third-party module)

I use the subprocess library and call another py file, but I get the error: No module named 'requests' I have this library installed and used in the called file. If I import this in the main file, it ...
Maylon's user avatar
  • 1
0 votes
0 answers
47 views

Python programme executes all lines but does not run any 'subprocess.Popen()' lines

I have simple Firefox add-on that, I am using it to test and discover the capabilities of Native Messaging, something I recently came across. The add-on side of things works as I expect it, nothing ...
Ralf_Reddings's user avatar
0 votes
0 answers
45 views

Subprocess Environment Variables and Python - pdflatex and git [duplicate]

I am trying to use pdflatex to compile some .tex documents that I am automatically producing by using Python. When trying to use pdflatex by itself it does nothing, as remarked by other users, even by ...
Andrumen1's user avatar
0 votes
0 answers
26 views

one global var with two values within 1 module after import

I have this multiload module that multiprocess.Popen two other modules. Module1 has to call a function in module2 and change a (for module2 global) var. But after that call there live two different ...
Plem's user avatar
  • 1
0 votes
0 answers
53 views

Run command via python with sudo and capture stdout

I want to run a sudo command from within python, because my script does a lot of things, that should be handled without the right necessary for commands like apt install. Further for most of those ...
MaKaNu's user avatar
  • 758
0 votes
0 answers
24 views

subprocess behavior when running script with redirect output

I have the following bash script: #!/bin/bash BIN_FOLDER=bin SEQ_BIN=some_binary PROFILE_FOLDER=profiles/ FILENAME=$1 mkdir -p $PROFILE_FOLDER sudo perf record -g -F 999 $BIN_FOLDER/$SEQ_BIN "$...
Diogo Almeida's user avatar
0 votes
1 answer
38 views

os.popen "sudo iwlist wlan0 scan" returns expected values when run stand-alone, but not under FLASK

I'm trying to update my Raspberry Pi python 3.x app to scan for nearby WiFi networks, but I can't get past an impasse with "sudo iwlist wlan0 scan". It's fine when executed as a standalone ...
greiginsydney's user avatar
-1 votes
0 answers
21 views

subprocess.run() looping inputs instead of EOF error when reading python script with a try except with a broad exception clause? [duplicate]

I'm having an issue where when subprocess.run() executes a Python script with a try-except in it with a broad exception clause, it will infinitely loop giving its input characters instead of only ...
Colbablast's user avatar
-1 votes
0 answers
36 views

How to play terminal-based games controlling the terminal through Python console

I'm trying to create a Python script that does the following things: creates a subprocess and starts a terminal game in in it (like space invaders) interacts continuously with the subprocess, by ...
Matteo Forasassi's user avatar
0 votes
1 answer
59 views

Call function(and pass var) in other running module that changes the vars there

As a beginner it is hard to formulate the question in one line. But the problem is: I have two modules running next to each other (with subprocess.Popen). I want to pass a var from module1 to a ...
Plem's user avatar
  • 1
0 votes
0 answers
14 views

What is the default timed out time for Popen.communicate?

In Python I am using subprocess to call a long running command and proc.communicate() so as to be able to log/print the output in realtime as shown here. However, I am getting a fatal: Application ...
Temp O'rary's user avatar
  • 5,476
0 votes
0 answers
18 views

fatal: Application timed out after 00:10:00.3431942

Packaged a MONAI Deploy app following the instructions here. Used the output docker image (MAP) as base image to create a new docker image using a Dockerfile. The Dockerfile is doing nothing much ...
Temp O'rary's user avatar
  • 5,476
0 votes
0 answers
25 views

Mrt.exe launch in python

How to launch MRT.exe in python? I tried writing method for launching this program in my python program. here is code: @typing.override @functools.cache def __interactive_mode__(self) -> None: ...
anonymous 6598's user avatar
0 votes
0 answers
11 views

Using backspace to clear input when running a program with subprocess.Popen()

I am currently trying to run a C program from python by using the subprocess.Popen method. Running a regular program is working fine. But when I run a program that requires an input, the input can be ...
A K's user avatar
  • 1
0 votes
1 answer
140 views

How to prevent a subprocess from outputting to stdout in Python?

I need to run a process using Python and kill it and then rerun it when it hangs. And I don't want the second process to contaminate my shell stdout. But no matter what I do, the subprocess's output ...
Mehran's user avatar
  • 15.8k
0 votes
0 answers
22 views

How do I send a command line input to another program that I cannot change with Python? [duplicate]

I have two programs - one that I am writing myself and one that I have to control a device that I cannot change. The program that controls the device is an .exe program that opens a command line input ...
Becky's user avatar
  • 1
1 vote
1 answer
50 views

Counter not updating in a while loop in the subprogram PYTHON 3.0 Rock Paper Scissors

from random import randint # ------------------------- # Subprograms # ------------------------- # Gets user input and directs it to the converter def get_player_choose(): global choose ...
MW2306RC's user avatar

1
2 3 4 5
245