Search code examples
pythonshellpython-webbrowser

python webbrowser leaves the shell open


I made a small python programm with the webbrowser modle wich is supposed to open a new tab in the browser and go to http://kivy.org/#home. I ran it with the linux shell and it worked fine, a new tab was opened and it went to http://kivy.org/#home. But when I wanted to run it again, I realised that I got the error message:

(process:9606): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed

And it looked like the Program was not closed because I could not type in anything, so I had to close it with ^C Here is my source code:

import webbrowser
webbrowser.open_new_tab('http://kivy.org/#home')

Solution

  • Python has a built-in function called quit(), no import required, it will terminate the script in your shell.

    import webbrowser
    webbrowser.open_new_tab('http://kivy.org/#home')
    quit()