25

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?

1 Answer 1

40

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.