Hi I would like to add a python kernal using IPython in Jupyter notebooks. The directory for the python exe can be found in "C:\Program Files\MSC.Software\MSC Apex\2021-782254\python3\python.exe" I would like to create a kernal which can access this python directory for code. This is because an external program uses a seperate python kernal but I have no idea how to link and create this using IPython.
Related
I am using Pycharm 2021.2.3 pro.
Is it possible to open a .py file as a jupyter notebook from within pycharm?
In the classical jupyter notebook, it is possible to open a .py file as a notebook and work with it like with a classical .ipynb (adding markdown etc.).
This allows to work on the full notebook without worrying about cells ordering like with a classical python script. When the script is ready, it is then possible to switch to the notebook view with its nice presentation features.
we did this when creating dash apps, you make the .py file upload and refer to it by way of importing as we do with regular python libraries
I'm writing a startup script for users of my Jupyter Lab extension that customizes the pandas dataframe output display using a formatter. The formatting only makes sense in the context of Jupyter Lab, but because the file is in the user's .ipython/profile_default/startup folder, it gets executed every time a IPython kernel is started.
I have tried using get_ipython().__class__.__name__, however 'ZMQInteractiveShell' is returned both in JupyterLab, Jupyter Notebooks, and VScode. I'm specifically looking for the case where the user is in Jupyter Lab.
Does anyone know how to detect if the IPython kernel was started by launching Jupyter Lab and either 1) preventing the startup file from running all together, or 2) just casing in my startup file itself to not load the formatter when it wasn't started through Jupyter Lab?
My startup file:
try:
import pandas as pd
def df_formatter(obj):
return f'<div><div onclick="console.log(\'You are in Jupyter Lab\'">In Jupyter Lab?</div> {obj.to_html()}</div>'
html_formatter = get_ipython().display_formatter.formatters['text/html']
html_formatter.for_type(pd.DataFrame, df_formatter)
except:
print('Unable to run startup script')
I would like to setup a system such that it not only runs jupyter notebook on start, but it also starts executing a specific notebook on that jupyter server (running all cells in sequence).
Is this possible? I specifically want to be able to access the notebook web interface and inspect/stop/etc the running notebook at any point.
I know nbconvert can execute a notebook, but it seems to run independently of any existing jupyter servers?
Maybe there is some API I can access so that I can write a shell script to run jupyter notebook and then use the API to open and run a notebook?
I am hoping to use pyRoot, the data analysis framework developed by CERN, by integrating it in a Jupyter notebook. That said, I believe that I did the proper installation of ROOT on my macOS 10.
When I launch the ROOT Jupyter notebook using the following command, it launches properly:
root --notebook
and I get the Jupyter notebook editor. However, whenever I start the notebook by:
import ROOT
The command is kept loading a pop up notification telling me that:
The kernel appears to have died. It will restart automatically.
I have some R code to update a database stored in update_db.ipynb. When I try to %run update_db.ipynb from a jupyter notebook with a python kernel, I get an error
File "<ipython-input-8-815efb9473c5>", line 14
city_weather <- function(start,end,airports){
^
SyntaxError: invalid syntax
Looks like it thinks that update_db.ipynb is written in python. Can I specify which kernel to use when I use %run?
Your error is not due to the kernel selected. Your command %runĀ is made to run python only, but it has to be a script, not a notebook. You can check in details the ipython magic commands
For your use case I would suggest to install both python and R kernel in jupyter. Then you can use the magic cell command %%R to select to run R kernel for a cell inside the python notebook. Source :this great article on jupyter - tip 19
Other solution is to put your R code in an R script, and then execute it from a jupyter notebook. For this you can run a bash command from a jupyter notebook that will execute the script
!R path/to/script.r