1

I want to execute one python script in Jupyter, but I don't want to use the web browser (IPython Interactive terminal), I want to run a single command in the Linux terminal to load & run the python script, so that I can get the output from Jupyter.

I tried to run jupyter notebook %run <my_script.py>, but it seems jupyter can't recognize %run variable.

Is it possible to do that?

0

3 Answers 3

3

The jupyter_client package has a jupyter run command since v5.0, so you can just do:

jupyter run my_script.py
Sign up to request clarification or add additional context in comments.

Comments

2

You can use the jupyter console -i command to run an interactive jupyter session in your terminal. From there you can run import <my_script.py>. Do note that this is not the intended use case of either jupyter or the notebook environment. You should run scripts using your normal python interpreter instead.

2 Comments

“this is not the intended use case of either jupyter or the notebook environment” who says that?
It is not an explicit statement, but the jupyter notebook runs as a web server locally, accessible in port 8888, to be operated in a web browser session.
0

You can run this command to run an interactive jupyter session in your terminal.

jupyter notebook

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.