openvpn3-indicator icon indicating copy to clipboard operation
openvpn3-indicator copied to clipboard

Set shebang as sytem python

Open SebCorbin opened this issue 7 months ago • 8 comments

I followed the installation instructions:

  • installed openvpn3-linux
  • added ppa
  • installed openvpn3-indicator

When I execute openvpn3-indicator, I get:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/bin/openvpn3-indicator/__main__.py", line 25, in <module>
  File "/usr/bin/openvpn3-indicator/openvpn3_indicator/__init__.py", line 35, in main
  File "/usr/bin/openvpn3-indicator/openvpn3_indicator/application.py", line 29, in <module>
ModuleNotFoundError: No module named 'dbus'

I tried pip installing dbus-python but then I get ModuleNotFoundError: No module named 'openvpn3'. I preferred to stop at this level of the rabbithole...

My config

$ cat /etc/lsb-release                                                                                                                                                                                                                                                       DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.2 LTS"
$ uname -m
x86_64

SebCorbin avatar May 14 '25 08:05 SebCorbin

i have the same ubuntu version and have no issue with it not technically a problem , since i do think it should start even when executed from the terminal ... but there should be an application shortcut in your applications menu to start from there (that should work)

you should check if you are using the system python binary which python3 for example i'm not using the system python for my account since i installed a different version using pyenv but openvpn3-indicator does work if i start it from the applications menu

that being said, i'm not a fan of the #!/usr/bin/env python3 shebang for system wide installed applications as i think this leads to problems more often than not

aduzsardi avatar May 14 '25 08:05 aduzsardi

Thanks for your reply, when I hit the app shortcut, it just won't start (endless loading), the syslog show the same error:

2025-05-14T11:57:53.138196+02:00 thinkpad-t14 systemd[2144]: Started app-gnome-net.openvpn.openvpn3_indicator-709994.scope - Application launched by gnome-shell.
2025-05-14T11:57:53.139574+02:00 thinkpad-t14 net.openvpn.openvpn3_indicator.desktop[709994]: Traceback (most recent call last):
2025-05-14T11:57:53.139689+02:00 thinkpad-t14 net.openvpn.openvpn3_indicator.desktop[709994]:   File "<frozen runpy>", line 198, in _run_module_as_main
2025-05-14T11:57:53.139708+02:00 thinkpad-t14 net.openvpn.openvpn3_indicator.desktop[709994]:   File "<frozen runpy>", line 88, in _run_code
2025-05-14T11:57:53.139724+02:00 thinkpad-t14 net.openvpn.openvpn3_indicator.desktop[709994]:   File "/usr/bin/openvpn3-indicator/__main__.py", line 25, in <module>
2025-05-14T11:57:53.139748+02:00 thinkpad-t14 net.openvpn.openvpn3_indicator.desktop[709994]:   File "/usr/bin/openvpn3-indicator/openvpn3_indicator/__init__.py", line 35, in main
2025-05-14T11:57:53.139774+02:00 thinkpad-t14 net.openvpn.openvpn3_indicator.desktop[709994]:   File "/usr/bin/openvpn3-indicator/openvpn3_indicator/application.py", line 29, in <module>
2025-05-14T11:57:53.139790+02:00 thinkpad-t14 net.openvpn.openvpn3_indicator.desktop[709994]: ModuleNotFoundError: No module named 'dbus'

I also happen to have pyenv, so that may be the issue:

$ which python3
/home/sebcorbin/.pyenv/shims/python3

SebCorbin avatar May 14 '25 10:05 SebCorbin

So setting temporarily pyenv global system then starting indicator solves the issue, but the shebang could be improved?

SebCorbin avatar May 14 '25 10:05 SebCorbin

Changed the Exec in /usr/share/applications/net.openvpn.openvpn3_indicator.desktop to

Exec=env PYENV_VERSION=system pyenv exec openvpn3-indicator

SebCorbin avatar May 14 '25 10:05 SebCorbin

in my opinion the devs should set the shebang to use /usr/bin/python3 hard-coded as that's the path that the desktop linux systems i've tried are using , namely any debian based system (mint,ubuntu, pop os, etc) , fedora based or suse/opensuse based all use /usr/bin/python3

aduzsardi avatar May 14 '25 10:05 aduzsardi

not sure why you marked as completed , it probably still is an outstanding issue for other people and one possible fix would be to set the the shebang of the python script to the system python3 executable as i mentioned above

aduzsardi avatar May 22 '25 05:05 aduzsardi

I'm not sure which behavior is really expected by users choosing a non default python environment. I guess it differs from one case to another. I'll investigate what is the default in other distributed projects and maybe change the shebang during the packaging process.

grzegorz-gutowski avatar May 22 '25 13:05 grzegorz-gutowski

@grzegorz-gutowski thanks for the involvement but i disagree with your statement you install these packages as system packages so the python modules (specifically the openvpn3 package) are installed for the system python not for your user environment , so running the app as the user env python doesn't really make sense.

it would have made sense (maybe) if the user installed the app locally and all it's dependencies for that user alone in it's home folder or something (not the case here)

aduzsardi avatar May 22 '25 13:05 aduzsardi

Latest commits change shebang to #!/usr/bin/python3 for packaged versions of openvpn3-indicator (launchpad and copr).

grzegorz-gutowski avatar Jun 09 '25 15:06 grzegorz-gutowski