When starting the GuPPy User Interface from a server running in 'headless' mode, there's an issue with 'TKAgg' backend.
The full error stack looks like this:
2023-09-07 16:44:46,478 Starting Bokeh server version 2.3.2 (running on Tornado 6.1)
2023-09-07 16:44:46,479 User authentication hooks NOT provided (default user enabled)
2023-09-07 16:44:46,482 Bokeh app running at: http://localhost:5006/savingInputParameters
2023-09-07 16:44:46,482 Starting Bokeh server with process id: 96012
2023-09-07 16:44:47,365 Error running application handler <bokeh.application.handlers.notebook.NotebookHandler object at 0x7ff0e76917b8>: Cannot load backend 'TKAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
File "pyplot.py", line 287, in switch_backend:
newbackend, required_framework, current_framework)) Traceback (most recent call last):
File "/home/wanglab/mambaforge/envs/guppy/lib/python3.6/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
exec(self._code, module.__dict__)
File "/home/wanglab/code/FP/GuPPy/GuPPy/savingInputParameters.ipynb", line 16, in <module>
"import numpy as np\n",
File "/home/wanglab/code/FP/GuPPy/GuPPy/preprocess.py", line 16, in <module>
plt.switch_backend('TKAgg')
File "/home/wanglab/mambaforge/envs/guppy/lib/python3.6/site-packages/matplotlib/pyplot.py", line 287, in switch_backend
newbackend, required_framework, current_framework))
ImportError: Cannot load backend 'TKAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
This issue can be resolved with using a virtual display server, such as:
sudo apt-get install xvfb
xvfb-run -a panel serve --show GuPPy/savingInputParameters.ipynb
Then the server runs fine (if using VS Code, it takes care of the required port forwarding).
2023-09-07 16:49:06,688 Starting Bokeh server version 2.3.2 (running on Tornado 6.1)
2023-09-07 16:49:06,689 User authentication hooks NOT provided (default user enabled)
2023-09-07 16:49:06,693 Bokeh app running at: http://localhost:5006/savingInputParameters
2023-09-07 16:49:06,693 Starting Bokeh server with process id: 97214
Launching server at http://localhost:44699
There may be other way to solve this. This one works for Linux servers / workstations at least.
When starting the GuPPy User Interface from a server running in 'headless' mode, there's an issue with 'TKAgg' backend. The full error stack looks like this:
panel serve --show GuPPy/savingInputParameters.ipynb
This issue can be resolved with using a virtual display server, such as:
Then the server runs fine (if using VS Code, it takes care of the required port forwarding).
There may be other way to solve this. This one works for Linux servers / workstations at least.