Chan Xiang
Chan Xiang

Reputation: 9

Python Tkinter GUI execute python script error

I use the below code for gui and the error say that no module named cv2, but if run it in ide or command prompt it work. Anyone else know what's the problem i faced or any suggestion?

os.system('python faceDetect.py')

Upvotes: 0

Views: 158

Answers (2)

Attila Viniczai
Attila Viniczai

Reputation: 693

For calling Python scripts from Python I recommend using runpy.run_module instead to avoid the overhead of spawning a new Python process:

import runpy
# Note that faceDetect.py must be available through PYTHON_PATH / sys.path
runpy.run_module('faceDetect', run_name='__main__')

Upvotes: 1

Super Sanglap
Super Sanglap

Reputation: 91

call it using subprocess.

import subprocess
subprocess.call('python faceDetect.py')

Upvotes: 0

Related Questions