Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PyCharm and Colab notebook documentation #6599

Merged
merged 5 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added doc/_static/images/colab-notebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/images/pycharm-notebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion doc/explanation/develop_seamlessly.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ template.main.append(p_hearts)
template.servable()
```

From the VS Code terminal run the following command.
From the terminal run the following command.

```bash
panel serve app.py --show --autoreload
Expand All @@ -163,5 +163,6 @@ The `--show` flag will open a browser tab with the live app and the `--autoreloa

### How-to

- [Configure PyCharm](../how_to/editor/pycharm_configure.md)
- [Configure VS Code](../how_to/editor/vscode_configure.md)
- [Write apps in Markdown](../how_to/editor/markdown.md)
10 changes: 10 additions & 0 deletions doc/how_to/editor/pycharm_configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ With the configuration in place, you can now easily `run` Panel apps via the `pa
With the configuration in place, you can now easily `debug` Panel apps via the `panel serve` configuration. The picture below shows debugging in action, where a breakpoint is hit when the Button is clicked.

![Debug Panel App in PyCharm](../../_static/images/pycharm-debug-panel.png)

## Notebook Environment

PyCharm Professional offers support for [Jupyter Notebooks](https://www.jetbrains.com/help/pycharm/ipython-notebook-support.html) and [ipywidgets](https://www.jetbrains.com/help/pycharm/interactive-js-widgets.html), enhancing interactive Python development.

To integrate Panel effectively, ensure the installation of `jupyter_bokeh` by executing `pip install jupyter_bokeh` or `conda install -c bokeh jupyter_bokeh`. Subsequently, activate the extension using `pn.extension()`.
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
philippjfr marked this conversation as resolved.
Show resolved Hide resolved

Below, observe the implementation of a notebook within the PyCharm Notebook Environment.

![Panel in PyCharm Notebook Environment](../../_static/images/pycharm-notebook.png)
40 changes: 34 additions & 6 deletions doc/how_to/notebook/other_nb.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,49 @@ This guide addresses how to develop apps in Google Colab, VSCode, nteract, and o

---

### Google Colab
## Google Colab

In the Google Colaboratory notebook, first make sure to load the `pn.extension()`. Panel objects will then render themselves if they are the last item in a notebook cell. Please note that in Colab rendering for each notebook cell is isolated, which means that every cell must reload the Panel extension code separately. This will result in somewhat slower and larger notebook than with other notebook technologies.
:::{tip}

### VSCode notebook
Before using a new [Colab notebook](https://colab.google/) you should make sure you are running on the latest version of Panel and that the latest version of [`jupyter_bokeh`](https://github.com/bokeh/jupyter_bokeh) is installed.

Visual Studio Code (VSCode) versions 2020.4.74986 and later support ipywidgets, and Panel objects can be used as ipywidgets since Panel 0.10 thanks to `jupyter_bokeh`, which means that you can now use Panel components interactively in VSCode. Ensure you install `jupyter_bokeh` with `pip install jupyter_bokeh` or `conda install -c bokeh jupyter_bokeh` and then enable the extension with `pn.extension()`.
You can update Panel and `jupyter_bokeh` with

```bash
!pip install panel param bokeh jupyter_bokeh -U
```

:::

In the Google Colaboratory notebook, first make sure to load the `pn.extension()`. As usual Panel objects will then render themselves if they are the last item in a notebook cell.

![Colab Panel Notebook](../../_static/images/colab-notebook.png)

:::{note}
Please note that in Colab rendering for each notebook cell is isolated, which means that every cell must reload the Panel extension code separately. This will result in somewhat slower and larger notebook than with other notebook technologies.
:::

:::{warning}
The [IpyWidgets](../../reference/panes/IpyWidget.ipynb) pane does not work in Google Colab. Thus you cannot use IpyWidgets with Panel in Colab.
:::

## PyCharm Notebook

PyCharm Professional offers support for [notebooks](https://www.jetbrains.com/help/pycharm/ipython-notebook-support.html) and [ipywidgets](https://www.jetbrains.com/help/pycharm/interactive-js-widgets.html). Thanks to the [`jupyter_bokeh`](https://github.com/bokeh/jupyter_bokeh) integration, Panel objects can be utilized as ipywidgets, allowing for interactive use of Panel components within PyCharm Professional. To ensure full functionality, install `jupyter_bokeh` using `pip install jupyter_bokeh` or `conda install -c bokeh jupyter_bokeh`, followed by activating the extension with `pn.extension()`.
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
philippjfr marked this conversation as resolved.
Show resolved Hide resolved

For additional guidance, refer to the [How-To Configure PyCharm Guide](../editor/pycharm_configure.md).

## VSCode notebook

Visual Studio Code (VS Code) supports notebooks and ipywidgets, and Panel objects can be used as ipywidgets thanks to [`jupyter_bokeh`](https://github.com/bokeh/jupyter_bokeh), which means that you can use Panel components interactively in VS Code. Ensure you install `jupyter_bokeh` with `pip install jupyter_bokeh` or `conda install -c bokeh jupyter_bokeh` and then enable the extension with `pn.extension()`.

See also the [How-To Configure VS Code Guide](../editor/vscode_configure.md).

### nteract and other ipywidgets notebooks
## nteract and other ipywidgets notebooks

In other notebook environments that support rendering ipywidgets interactively, such as nteract, you can use the same underlying ipywidgets support as for vscode: Install ``jupyter_bokeh`` and then use ``pn.extension(comms='ipywidgets')``.

### Other environments
## Other environments

If your development environment offers embedded Python processes but does not support ipywidgets or Jupyter "comms" (communication channels), you will notice that some or all interactive functionality is missing. Some widgets that operate only in JavaScript will work fine, but others require communication channels between JavaScript and Python. In such cases you can either request ipywidgets or Panel support from the editor or environment, or else use the Editor + Server approach above.

Expand Down
3 changes: 2 additions & 1 deletion doc/tutorials/basic/develop_editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ For more advanced techniques and configuration options, check out the resources

### How-to

- [Configure VS Code](../../how_to/editor/vscode_configure.md)
- [Configure PyCharm](../../how_to/editor/vscode_configure.md)
- [Configure VS Code](../../how_to/editor/pycharm_configure.md)
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
- [Write Apps in Markdown](../../how_to/editor/markdown.md)

Happy coding! 🚀
3 changes: 2 additions & 1 deletion doc/tutorials/basic/develop_notebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ For more detailed instructions and explanations, check out the resources below:
- [Display Output in Notebooks](../../how_to/notebook/notebook.md)
- [Preview Apps in JupyterLab](../../how_to/notebook/jupyterlabpreview.md)
- [Serve an App from a Notebook File](serve.md)
- [Use VS Code Notebook and Interactive Environment](https://panel.holoviz.org//how_to/editor/vscode_configure.html#notebook-and-interactive-environment)
- [Use PyCharm Notebook Environment](https://panel.holoviz.org/how_to/editor/pycharm_configure.html#notebook-environment)
- [Use VS Code Notebook and Interactive Environment](https://panel.holoviz.org/how_to/editor/vscode_configure.html#notebook-and-interactive-environment)
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
philippjfr marked this conversation as resolved.
Show resolved Hide resolved

Happy developing! 🚀
1 change: 1 addition & 0 deletions doc/tutorials/intermediate/develop_editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ You have learned to
### How-to
- [Configure PyCharm](../../how_to/editor/pycharm_configure.md)
- [Configure VS Code](../../how_to/editor/vscode_configure.md)
## Explanation
Expand Down
Loading