How do I change default code formatter in Jupyter Lab? - jupyter-lab

There is some information here, but it's not clear where to put the code.
My main task is to use black or autopep8 formatter for the whole notebook

Related

IPython shell via embed() not showing colors

I use the following snippet to drop to an interactive IPython CLI from my code:
from IPython import embed
# do some things
embed()
But no syntax highlighting or any other color shows up.
If, in contrast, I start ipython simply with
ipython3
Then colors show up as expected.
How can I get colors/syntax highlighting when embedding IPython like this?
IPython==7.21.0
python3==3.7.5
Also on gh issues
Has posted on Github by me
This is a known problem as you can see here
I suggest you to run your code as follow:
from IPython import embed
# do some things
embed(colors="neutral")
The supported colors are (as you can read here): Neutral, NoColor, LightBG, Linux

How can Pycharm (with matplotlib) show me my graphs in the same Py charm, next to my code?. Not in additional windows

i am using Matplotlib with Pycharm in a Mac osx. When I am making a graph, and I code plt.show() pycharm opens another window. And if there is 2 graphs, to see the 2nd one I have to close the first one. And I want to see both together.
There is a option to show the two graph in the same window, where my code is?
Thanks very much.
This link may help:
IPython magic commands
Using Jupyter notebooks you can achieve what you want by using %matplotlib inline. It seems from the link above that PyCharm may have some way to enable this same functionality.
See also: Inline plots in the scientific view

Choose kernel from the terminal when launching jupyter notebook. Can it be done?

The command:
jupyter notebook blah.ipynb
will launch the notebook. But I want it to use a specific kernel called my_fav_kernel (it is listed in kernel > change kernel menu).
Can I change the CLI incantation I use to invoke jupyter to directly use
my_fav_kernel instead of having to mouse-click
kernel > change kernel menu > my_fav_kernel every time?
If you save the notebook after selecting a kernel, the next time your notebook will start with your selected kernel.
Alternatively, something like the following works for me:
jupyter notebook --MultiKernelManager.default_kernel_name=my_fav_kernel
Check Jupyter documentation for more information.
The Jupyter documentation discusses this. Search the page for the following:
NotebookApp.kernel_manager_class : Type
Default: 'notebook.services.kernels.kernelmanager.MappingKernelManager'
Here is an example of how to use it; you will probably need to provide the full package for my_fav_kernel:
jupyter notebook --NotebookApp.kernel_manager_class=my_fav_kernel blah.ipynb

Highlight to select and Middle-button to paste in jupyter notebook?

In Jupyter Notebook, when I highlight text either from within a cell in the notebook or from outside the notebook, Middle-Button click doesn't paste anything as it is supposed to do in many other applications in linux. Is there any setting that would allow one to be able to paste with a Middle-Button click into an Ipython or Jupyter Notebook?
I'm using the notebook in firefox if that matters.
The fact that you're using Firefox definitely matters. See this issue on CodeMirror (CodeMirror is the text editor that Juypter uses): Issue #931
In that thread, it references this Firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=846674
It seems as though the issue has only recently been fixed, so it may take a little bit to trickle into CodeMirror. You may want to comment on the issue in CodeMirror to inform them that the issue has been fixed on FF and it might prompt them to investigate.
However, Jupyter doesn't automatically use the most recent version of CodeMirror so again you may have to wait a while. If this issue is truly critical then I suggest switching to another browser.

Widgets not showing in NBViewer

I have an iPython Notebook with an interactive slider widget:
To share the notebook, I would like to use the link provided by NBViewer. This would allow me to share the notebook with people that don't use Python. Unfortunately, the widget does not show when viewing the NBViewer link:
Is there something I need to do to make widgets work with NBViewer?
Widgets are not shown in nbviewer with current ipython 2.x.
IPython 3 is supposed to add persistent widgets that can be shown by nbviewer.
The release of ipython 3 was scheduled for this fall but it is likely to happen early next year.
I had to downgrade ipywidget from version 7.0.3 to get nbviewer showing ipywidget.
pip install ipywidgets==6.0.0

Resources