How to force the ipynb code run sequentially

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

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

        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