# Triggering a python script that opens a browser window

**URL:** <https://discourse.nodered.org/t/triggering-a-python-script-that-opens-a-browser-window/73709>\
**Category:** General\
**Created:** [15 January 2023 13:45 UTC](https://discourse.nodered.org/t/triggering-a-python-script-that-opens-a-browser-window/73709 "2023-01-15T13:45:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ostiniatoze](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ostiniatoze/32/54860_2.png) [@ostiniatoze](https://discourse.nodered.org/u/ostiniatoze)\
**Post date:** [15 January 2023 13:45 UTC](https://discourse.nodered.org/t/triggering-a-python-script-that-opens-a-browser-window/73709/1 "2023-01-15T13:45:59Z")

</div>

I'd like to use the exec node to run a script that will open a browser window to download a file. The script runs fine when run from the command line but nothing happens when I run it using the exec node, there's no error or anything with the debug node.  
I'm running nodered on a raspberry pi4, and the code that opens it is ` webbrowser.open_new(downloadurl)`  
I appreciate any help, please let me know if more info would be helpful

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 January 2023 18:21 UTC](https://discourse.nodered.org/t/triggering-a-python-script-that-opens-a-browser-window/73709/2 "2023-01-15T18:21:47Z")

</div>

Have you checked for error output?

Most likely, the Node-RED runtime environment does not have a ui. So the browser cannot start.

---

<div class="post-metadata">

**Author:** ![ostiniatoze](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ostiniatoze/32/54860_2.png) [@ostiniatoze](https://discourse.nodered.org/u/ostiniatoze)\
**Post date:** [18 January 2023 13:17 UTC](https://discourse.nodered.org/t/triggering-a-python-script-that-opens-a-browser-window/73709/3 "2023-01-18T13:17:27Z")

</div>

That was it, thank you very much.

Solution: Include the following in the script

> from pyvirtualdisplay import Display  
> display = Display(visible=0, size=(800, 600))  
> display.start()

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 February 2023 13:17 UTC](https://discourse.nodered.org/t/triggering-a-python-script-that-opens-a-browser-window/73709/4 "2023-02-01T13:17:40Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
