I needed to write a script with configuration environment in only one cell. I want to leave it indented
!(python --version
which python
pip --version
conda --version
which conda) >> config-environment.txt
But cell not acept skip line between each command. How to write? Is it possible write bash script with indented in jupyter-notebook?
Jupyter Notebook - Big Data Visualization Tool In order to enter more than one statements in a single input cell, press ctrl+enter after the first line. Subsequently, just pressing enter will go on adding new line in the same cell. To stop entering new lines and running cell, press enter key one more time at the end.
Using a backslash \ or « to print a bash multiline command If you're writing a multiline command for bash, then you must add a backslash (\) at the end of each line. For multiline comments, you have to use the HereDoc « tag.
ctrl+o. If you type ctrl+o, you should be able to add additional lines to the input to run them simultaneously. If that doesn't work, as a workaround, you can paste multiple lines after copying them from elsewhere, or you can press enter on a line with a semicolon or unclosed parentheses.
For your particular case, you can simply use semicolon at the end to run it i.e.
!(python --version; \
which python; \
pip --version; \
conda --version; \
which conda) >> config-environment.txt
For general case, you can use %%bash
cell magic command to run the cell in bash i.e.
%%bash script magic
Run cells with bash in a subprocess.
%%bash
(python --version
which python
pip --version
conda --version
which conda) >> config-environment.txt
You can also have a look at subprocess
python module.
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