How to force the ipynb code run sequentially

When writing the ipynb code, I found that it does not run sequentially:

        os.chdir(input_path)     
         file1= shutil.copyfile(...)   
       (.. doing the first turn calculation using the copied files)

        os.chdir(output_path)
        file2= shutil.copyfile(...)
         (.. doing the second turn of calculation using the newly copied files)

It shows that when doing the first turn, file2 has been copied into the folder, which may result in the disorder in the calculation since the calculation relies on the extension of the filename.

How can I fix the problem?

Maybe the shutil.copyfile calls a child process, so it goes to the next step before copying is complete. You could try:

import os

os.system('cp 1.txt.py 2.txt.py')