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!
Advertisement
Answer
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:
- Run the code on a Unix/Linux machine which has the
head
command. - Skip the command as it probably will not affect the rest of your code as it is meant to just show you the first 10 lines in the file, which you could just do by opening the file in a text editor.
- Replace the command with an alternative command for
head
in Windows to perform the same function, although AFAIK, there isn’t a direct equivalent.