Search code examples
pythonsubprocessnotepad++

After calling NotePad++ using subprocess, Python won't start executing other codes until I close the Notepad program


I am trying to open a .txt file using NotePad++ in Python IDE using subprocess.call function. One issue I needed help is that once I execute below codes:
subprocess.call([r"C:\Program Files\Notepad++\notepad++.exe", r"C:\location\myfile.txt"])
Python won't start executing other codes untiless I close the Notepad++ program. I have to use Ctrl+C to stop it. What I am trying to do here is to open a file and view it, but I need my code to continue running other functions instead of wait for me to close the NotePad++ program. Does anyone know how to solve it? Thank you!


Solution

  • This might help: Python-calling-script-without-waiting-for-it-to-execute

    You should use

    subprocess.Popen
    

    instead of

    subprocess.call