Ask Your Question
0

What is the procedure to utilize IPython.notebook.kernel.execute in Azure Databricks?

asked 2021-10-30 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-05-11 08:00:00 +0000

pufferfish gravatar image

To utilize IPython.notebook.kernel.execute in Azure Databricks, follow these steps:

  1. Open the Databricks notebook in which you want to use IPython.notebook.kernel.execute.

  2. Click on the "Settings" tab on the top right-hand side of the notebook.

  3. Scroll down to find "Advanced Options" and click on it.

  4. In "Advanced Options," you will see an input box named "Initialization Script." Add the following code in the input box:

    if get_ipython().__class__.__name__ == 'ZMQInteractiveShell':
        from IPython import get_ipython
        get_ipython().kernel.do_execute('%alias_magic --line shell /bin/bash')
    

    This code will enable the Magic alias shell command inside the notebook.

  5. Now, add your own code in a new cell and write the following line of code in it:

    IPython.notebook.kernel.execute("your code here")
    

    This line of code will execute your code using the notebook kernel.

  6. Finally, you can run the cell to test the execution of your code.

Note: Make sure that you have installed and imported IPython in your notebook.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-30 11:00:00 +0000

Seen: 12 times

Last updated: May 11 '22