henrysher / duplicity

mirror of duplicity: https://code.launchpad.net/duplicity
81 stars 13 forks source link

B2 backend import error message could reveal the missing module #14

Open jshprentz opened 6 years ago

jshprentz commented 6 years ago

While trying to backup to Backblaze, Duplicity raised a BackendException reporting, "B2 backend requires B2 Python APIs (pip install b2)". The b2 module already was installed, but supporting SQLite development files were not, so the actual import failure was for the _sqlite3 module. An improved BackendException message could reveal the actual problem and reduce debugging time.

Environment

My server runs Ubuntu 14.04, which froze Python at version 2.7.6. To satisfy Duplicity's need for version 2.7.9 or later, I downloaded and compiled the latest Python 2.7, which is version 2.7.14. My Ubuntu server lacked the SQLite 3 development files, so my Python build omitted SQLite support.

I corrected the problem by installing the Ubuntu libsqlite3-dev package, rebuilding Python, and rebuilding Duplicity. With SQLite support in Python, Duplicity successfully backs up to Backblaze.

NZJourneyMan commented 6 years ago

I also had similar issues with the BackendException not reporting the underlying issue. In my case I guessed what the issue was and ran the b2 executable directly which gave me a stacktrace telling me what module was missing and how to fix it. The underlying issue is the b2 pip package is missing one or more dependencies.

tobypeschel commented 5 years ago

I've run into this issue multiple times, and each time it's urllib3 with b2.api. A quick pip install urllib3 --upgrade fixes it, in my case from version urllib3-1.22 to urllib3-1.25.6. I agree BackendException could be more detailed.

mauricev commented 4 years ago

This bug has still not been fixed. I am getting "b2" not being installed. But what I installed is b2sdk, so is it looking for the wrong thing?

mauricev commented 4 years ago

When I manually loaded each module, for the first one, from b2sdk.api import B2Api, I got ModuleNotFoundError: No module named 'sqlite3'

Not sure why the error code suggested above reported "b2" and not sqlite3, but the cause in my case is the same as the original poster's.

cosimo commented 3 years ago

When I manually loaded each module, for the first one, from b2sdk.api import B2Api, I got ModuleNotFoundError: No module named 'sqlite3'

Not sure why the error code suggested above reported "b2" and not sqlite3, but the cause in my case is the same as the original poster's.

@mauricev, I think that on python 2.7 you need to downgrade the b2 module. I did and that worked for me.

 pip install b2==1.0.0

(or try different values for the version number).

Rufflewind commented 3 years ago

Merge request to partially mitigate this issue on Python 3.6+: https://gitlab.com/duplicity/duplicity/-/merge_requests/33

asgh commented 3 years ago

b2 version 1.4.2 and b2sdk version 1.1.4 work.