1
votes
from subprocess import Popen,PIPE
from Tkinter import *
root=Tk()
calc=Frame(root)
calc.grid()
root.title("Calculator")
bt=Button(calc,text="3")
bt.grid()
process=subprocess.Popen(['python','imacap.py'],stderr=subprocess.STDOUT,  stdout=subprocess.PIPE)

In given code I created GUI using tkinter in python. While displaying GUI app, I want to run camera capturing app at the same time so after googling it I found solution of using subprocess.Popen. So I created imacap.py and used in it. But now I am facing error as Traceback (most recent call last):

File "/home/mukund/testa.py", line 9, in process=subprocess.Popen(['python','imacap.py'], stderr=subprocess.STDOUT, stdout=subprocess.PIPE) NameError: name 'subprocess' is not defined

2
You have imported Popen not subprocess. Please use import subprocess - lima

2 Answers

3
votes

You are importing Popen and PIPE from subprocess. Now you can access Popen or PIPE directly, no need of subprocess as prefix.

If you want to use subprocess as prefix then change your import.

import subprocess

Then subprocess.Popen will work.

2
votes

you should change your import to "import subprocess"