import subprocess from Npp import notepad si = subprocess.STARTUPINFO() si.dwFlags |= subprocess.STARTF_USESHOWWINDOW python_path = subprocess.check_output('where pythonw.exe',startupinfo = si).rstrip() script_path = 'query.py' result = subprocess.check_output([python_path,script_path]).rstrip() # print(result) if result != 'None': notepad.open(result)