Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using bash commands in jupyter notebook

I never used bash with jupyter notebook. For some project, I need to use bash with python but it's giving me errors. I have installed bash kernel also.

PATH="/Downloads/dogscats/"
!ls {PATH}

'ls' is not recognized as an internal or external command, operable program or batch file.

like image 739
Karan Purohit Avatar asked Mar 08 '23 00:03

Karan Purohit


1 Answers

It is possible to use bash commands in Jupyter Notebook, even on Windows systems, as long as Jupyter is launched from a bash-compliant command line such as Git Bash (MingW64). As shown in the OP's code example, the bash command must be prepended by an exclamation mark (!).

The real key, however, is launching from Git Bash or possibly Ubuntu on Windows .

I'm running windows 10 Pro with Python installed via Anaconda, and the following code works when I launch Jupyter via Git Bash, but does not when I launch from the Anaconda prompt.

>>> !ls
database.sqlite
Weather Data Clustering using k-Means.ipynb

>>>!pip show lxml | grep Version
Version: 4.1.0
like image 84
Karl Baker Avatar answered Mar 21 '23 08:03

Karl Baker