I am trying to run the following in Jupyter notebook (with Python 2 if it makes a difference):
!head xyz.txt
and I get the following error:
'head' is not recognized as an internal or external command, operable program or batch file.
Is there anything I need to import to be able to do this?
You can run anything in your system shell with a terminal, including programs such as vim or emacs. The terminals run on the system where the Jupyter server is running, with the privileges of your user. Thus, if JupyterLab is installed on your local machine, the JupyterLab terminals will run there.
Linux commands and exercises are designed to be executed from a Linux terminal. However, there are several different ways that most of this functionality can be achieved from the Jupyter notebooks with the attendent advantage of built-in documentation capabilities.
Might be useful for others. Use ! followed by terminal command you want to execute. To run a shell command. E.g.,
! pip install some_package
to install the some_package.
An easier way to invoke terminal using jupyter-notebooks is to use magic function %%bash
and use the jupyter cell as a terminal:
%%bash head xyz.txt pip install keras git add model.h5.dvc data.dvc metrics.json git commit -m "Second model, trained with 2000 images"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With