Saturday 21 August 2021

No application is registered as handling this file in bundled Python program

I am using Ubuntu 21.04 with Python 3.8, Matplotlitb 3.4.3, pyinstaller 4.5.1 and I would like python program to open google.com page in default web browser. There is also matplotlib package (the reason why it's not working, without matplotlib everything is fine).

#!/usr/bin/python3
import webbrowser
import matplotlib.pyplot as plt

plt.plot([1, 2, 4, 8, 16])
plt.show()

webbrowser.open("https://www.google.com/")

When I run this program as ./main.py or python3 main.py, everything is ok and Google Chrome is opened. However when I bundle program into executable using pyinstaller:

pyinstaller --onefile main.py

And run this bundled program as ./dist/main, following error appears in terminal:

gio https://www.google.com/: No application is registered as handling this file

When I define BROWSER variable before running file, then it work again:

export BROWSER=$(which google-chrome) && ./dist/main

However, I would like to run program without declaring that variable. Default browser doesn't have to be Chrome and even OS doesn't have to be Linux, but eg. Windows. I found question with similar problem. But when I downgrade matplotlib from 3.4.3 to 3.0.3 is in the link, there is a lot of compatibility errors. So I would like to keep newest matplotlib.

Is there any way fix the gio error?



from No application is registered as handling this file in bundled Python program

No comments:

Post a Comment