pythonjupyter-notebookflopy

FloPy: 'head' is not recognized as an internal or external command, operable program or batch file


I am trying to run the flopy3_modflow_boundaries example from the FloPy Jupyter Notebook. The notebooks have worked perfectly well for earlier examples (including building, displaying images, running a MODFLOW-NWT model, and viewing the results...so I think have things substantially set up correctly), but for some reason when it gets to the following section of code:

!head -n 10 'data/test.riv'

I get the following error:

'head' is not recognized as an internal or external command,

operable program or batch file.

I'm not sure what the "!head" code with the exclamation mark is supposed to do, or how I can fix the error. If it matters, I'm running Python 3.9 on Windows 7. "Head" is a groundwater term, so I assume it is imported from FloPy in the first step of the notebook?

Thanks!


Solution

  • head is a Unix/Linux shell command to show the first n lines in a file. So running head -n 10 'data/test.riv' would output the first 10 lines in file data/test.riv. Note that when you precede a command with ! in a Jupyter cell, it runs the command as it would in a terminal, and not as Python code.

    You can do any of the following: