-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backintime-qt script uses non-absolute python3 call #1316
Comments
Thanks a lot for sharing! We're still getting settled in with a new maintenance team, but we'll take a look at what's going on, and how your personal hotfix may improve things for everyone :) |
@eddgrant Awesome. Thank you so much for reporting and analysing this. I'm not well experienced with virtual environments (e.g. If I understood you correct you run backintime in a virtuell environment? How can this happen? Or somehow the btw: Maybe a @emtiu Didn't we had other issues with importing When migrating to the "src" Layout (far away in the future) this won't happen because python (or EDIT: To improve diagnosis. Can you please add a line before the last line in your
into this please
This should print the path to the used python interpreter binary on stdout. |
From a quick search, that would be:
So, this one looks unique to me at first glance. |
How did you installed pyenv? Did you build and installed it direct from github? It seems to me not installable via pip. Reading further into the docu of |
@buhtzz , here's the extra diagnostic info you asked for: ➜ ~ backintime-qt
/home/egrant/.pyenv/versions/3.9.9/bin/python3
Traceback (most recent call last):
File "/usr/share/backintime/qt/app.py", line 35, in <module>
import qttools
File "/usr/share/backintime/qt/qttools.py", line 21, in <module>
from PyQt5.QtGui import (QFont, QColor, QKeySequence)
ModuleNotFoundError: No module named 'PyQt5' Looks like its using my pyenv default Python runtime (which it calls "global"), which is currently set to ➜ ~ pyenv global
3.9.9 |
I think my pyenv installation probably pre-dates the automatic installer. IIRC I installed pyenv simply by cloning the git repo e.g.
|
@buhtzz I think your understanding of how pyenv works sounds correct (at least to me!). As I understand it pyenv is initialised when a shell is started, which in turn executes its initialisation file ( |
Referring to your headline I would say it isn't the responsibility of an application to point to the correct (specific) interpreter. BIT says it needs Python version 3 and then take what the operating system (or shell) does offer. In your case you kind of "hack" a bit and manage multiple python interpreters of different versions beside the operating systems itself. PyEnv "steal" the responsibility from the OS. IMHO the reasons for that Issue is that you misused PyEnv. Use PyEnv to get the correct interpreter and its site-packages. Then it should work. Maybe PyEnv is able to point to the original OS own interpreter, too. BackgroundPyEnv isn't a virtual environment. It is just kind of a Python interpreter switcher enabling you to install multiple Python interpreters of different versions all with there own site-packages. You can switch between them. The selection is globally in the current shell valid. It is not restricted to a specific folder. My opinionBecause of that I vote for Close. ConsequencesDespite that your report is valuable. It points me to an improvement for our diagnostics module. |
@eddgrant Excellent problem analysis - thanks a lot for sharing your knowledge here!
I fully understand that manipulating the search path (like
and that users doing this are fully responsible for the impact. But: IMHO we should prevent starting the wrong (non-OS-packages) python version for packaged BiT versions to reduce support efforts. I don't know how, but the OS package maintainers could possibly be able to solve this (it is a packaging issue IMHO). @buhtzz How about discussing this eg. with the DEBIAN package maintainer of BiT as a starting point, AFAIR you have an account there. What do you think? |
I see no need to discuss this with distro maintainers. It is not easy to argument here in my non-native English. 😄 The use case described here violates the concept of responsibilities. A userland application with dependencies to extern components (packages, libraries or an inpterprete like python2/3) never specifies the path to them explicit. When you "hack" that concept via a python-interpreter-switcher like This is Issues is not a bug. It is a misuse of It would violate a lot of concepts if BIT would specify an explicit path to the python interpreter.
@eddgrant You should be able to start BIT with your I vote for close because this is not a BIT bug but a misuse of on external tool.
There is no usual way for BIT to know what is "wrong". But I will add the used python binary path to the diagnostics in the next days.
They still do because they are responsible for what "python3" in there system means. |
I think @eddgrant opened this issue more with the intention to share his insights and less to urge a fix. Nevertheless if I
I think a simple
Edit: If this shouldn't use the correct python version the package maintainers of BiT will come back to us anyhow ;-) Edit 2: BiT common (CLI) is also affected by this issue... Edit 3: Should we also add the path to the active python file to our diagnostics output ( |
@eddgrant I would like to apologize for this. After I had read that again, it struck me that this could be understood very impolitely. It was not meant that way and can possibly be explained with my rather rough English. Although the latter may also not always be the excuse. |
As a disclaimer I have to say that my opinion is based on experience not on expertise. 😄 It is just how I understood the relationship between OS, envrionment, userland applications etc. I don't have hard facts here to support my opinion. So maybe I'm totally wrong here. I still don't see an advantage in modifying the starter script. I'm scared about a lot of upcoming side effects. And this situation described by @eddgrant is an unusual and rare use case. And you can use BIT in virtenv and pyenv when you have a correct setup of such special envrionments.
I would suggest to contact distro maintainers before modify something and ask them for an opinion. Maybe we could open an Issue or contact them directly. I would suggest to open an official debian report and mail to the maintainers after one week of no response.
See #1318. It is IMHO implemented.
|
OK, so let's settle this with "watch status" (don't change anything for now) The new |
Thanks for a thorough discussion, everyone. And thanks @buhtzz for explaining to @eddgrant that you meant no insult :) I agree with @buhtzz that it's a sane default for a caller script to simply call We might put I also agree with @aryoda that we should keep this Issue open for reference. Python is a lively language, and conditions might change. Again, thanks @eddgrant for sharing! |
@emtiu Do you have an idea for a new label with a self-explanatory name ("watchlist" or better) for this type of issue status? |
IMHO,
Discussion
|
@emtiu I would interpret "Discussion" as an active discourse or waiting for an answer to a question. Let's keep "Discussion", it is a good filter to be revisited again from time to time... |
I just stumbled across the solution how to inject the OS-specific python path into all launcher scripts and configurations: Via This is what package maintainers call when preparing a package (together with If we extend the existing logic to inject python2 vs. python3 by also injecting the absolute path (eg. found with Lines 133 to 141 in b4dd2d1
|
That sounds like it should work. It would be a lot of effort to test, and we can't cover all bases, but it seems reasonable. |
Yes, too much efforts for now, let' stick to the BTW: You will find me quite often posting "how it could be fixed" or at least "how does the current implementation work" comments even for non-HIGH issues because I am trying to understand the BiT full code base by digging into issues. This does not imply "must be fixed [at all or right now]" unless the fix is trivial and low-risk... |
Related to (already closed) issue #677 (comment) |
FYI: OpenSuse 15.3 uses this command in the installation script of the BiT package (v1.2.1): https://build.opensuse.org/package/view_file/openSUSE:Leap:15.3/backintime/backintime.spec?expand=1
|
Let's review this issue after #1575 (migration to Python build system) is done. |
I think we should close this issue after a cooling-off period of a few weeks since we have merged PR #1602 to solve this: It is possible to configure an absolute path to python3 with By default we still use no absolute path for the BiT starter scripts... |
Closing this ticket based on the comment above. Feel free to reopen Best regards, |
Hey folks,
This was baffling me for ages, but I had a flash of inspiration which led me to understand what was going on so I thought I'd share what I have found.
At some point recently the backintime GUI stopped working for me. I initially thought this might have been due to my recent upgrade to Ubuntu 22.04 LTS but none of the solutions I found helped my particular issue.
When I run
/usr/bin/backintime-qt
I got the following error:My initial thought was that I was somehow missing the
PyQt5
package so I checked usingpip3 freeze | grep PyQt5
and it confirmed that I hadPyQt5
installed:pip3 freeze | grep PyQt5 PyQt5==5.15.6 PyQt5-sip==12.9.1
I then looked at the contents of
/usr/bin/backintime-qt
and noticed that it has the#!/bin/sh
shebang line. Furthermore when it calls out to python (python3 -Es ${APP_PATH}/app.py "$@"
) it doesn't specify the path to the python binary.I think what was happening in my case was that my pyenv configuration was being initialised in the process in which
backintime-qt
was being run. When it initialised pyenv inserts various "shims" in to thePATH
environment variable, with the intention of providing access to a specific Python runtime. Thebackintime-qt
script seems to be expecting to use the system python runtime.To test this I replaced the line which calls out to python with the following, which ensures that it calls my system python runtime:
Lo and behold this resolves the issue and the backintime GUI now works for me again.
I'm not sure what a "proper" fix might look like here, as I'm aware that hard coding the path to the python runtime might not be portable across all Linux distros. I did wonder if there was a way to ensure the
backintime-qt
script was run in a "non-interactive" way, in the hope this might avoidpyenv
and other similar tools from polluting backintime's environment, but I didn't have any luck when testing this.Anyway, thought this was worth sharing and hope this helps someone.
P.S. BackInTime is a fabulous tool, much better than Ubuntu's default backup tool. Thanks for the time and effort spent on it! 🙌
The text was updated successfully, but these errors were encountered: