简体   繁体   中英

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')

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__')

call it using subprocess .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM