1
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

1
  • 2
    You have imported Popen not subprocess. Please use import subprocess Commented Feb 27, 2014 at 9:03

2 Answers 2

3

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.

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

Comments

2

you should change your import to "import subprocess"

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.