mikelolasagasti / revelation

Revelation is a password manager for the GNOME desktop, released under the GNU GPL license. It stores all your accounts and passwords in a single, secure place, and gives you access to it through a user-friendly graphical interface.
https://revelation.olasagasti.info
GNU General Public License v2.0
55 stars 24 forks source link

ImportError: cannot import name 'config' from partially initialized module 'revelation' #26

Closed tpapp closed 3 years ago

tpapp commented 4 years ago

Thanks for picking up maintenance of this great tool! I tried to get it working on Ubuntu 20.04, but get the following error after I compile (./autogen.sh && ./configure && make). This is on latest master (1ef9925).

$ ./src/revelation.py                                                                                                                                                                                                                                                             Traceback (most recent call last):
  File "./src/revelation.py", line 30, in <module>
    from revelation import config, data, datahandler, dialog, entry, io, ui, util
  File "/home/tamas/src/revelation/src/revelation.py", line 30, in <module>
    from revelation import config, data, datahandler, dialog, entry, io, ui, util
ImportError: cannot import name 'config' from partially initialized module 'revelation' (most likely due to a circular import) (/home/tamas/src/revelation/src/revelation.py)
mikelolasagasti commented 4 years ago

Can you try with sudo make install? It should work that way

tpapp commented 4 years ago

Is it possible to install somewhere in $HOME? Tried with

$ ./configure --prefix=$HOME/tmp/revelation
$ make
$ make install

and got


Note that '/home/tamas/tmp/revelation/share' is not in the search path
set by the XDG_DATA_HOME and XDG_DATA_DIRS
environment variables, so applications may not
be able to find it until you set them. The
directories currently searched are:

- /home/tamas/.local/share
- /usr/share/xfce4
- /usr/share/xubuntu
- /usr/local/share
- /usr/share
- /var/lib/snapd/desktop
- /usr/share

/usr/bin/update-desktop-database
Error in file "/usr/share/applications/org.kde.kdeconnect_open.desktop": "*/*" is an invalid MIME type ("*" is an unregistered media type)
Error in file "/usr/share/applications/org.kde.kdeconnect_open.desktop": "*/*" is an invalid MIME type ("*" is an unregistered media type)
The databases in [/usr/share/xfce4/applications, /usr/share/xubuntu/applications, /usr/local/share/applications, /usr/share/applications, /var/lib/snapd/desktop/applications, /usr/share/applications] could not be updated.
make[4]: *** [Makefile:548: install-data-hook] Error 1
make[4]: Leaving directory '/home/tamas/src/revelation/data/mime'
make[3]: *** [Makefile:480: install-data-am] Error 2
make[3]: Leaving directory '/home/tamas/src/revelation/data/mime'
make[2]: *** [Makefile:433: install-am] Error 2
make[2]: Leaving directory '/home/tamas/src/revelation/data/mime'
make[1]: *** [Makefile:422: install-recursive] Error 1
make[1]: Leaving directory '/home/tamas/src/revelation/data'
make: *** [Makefile:394: install-recursive] Error 1
janvrany commented 4 years ago

I just run into the same problem as @tpapp , but there was more.

After some hacking, I got it working in non-standard location (--prefix=/opt/revelation). Here's what I had to do:

  1. Add @pyexecdir@ to sys.path in revelation.py. See 0001-Add-pyexecdir-to-Python-sys.path.patch.txt. See commit message for details.

  2. Changed makefiles to install revelation.* icon into different directory. See 0002-Install-Revelation-icon-in-Revelation-s-own-data-dir.patch.txt. See commit message for details.

  3. Finally, manually copied data/schemas/gschemas.compiled to ${prefix}/share/revelation/schemas/gschemas.compiled. Sorry, no patch for this yet, I'm not familiar enough with automake to understand how to add this to make install.

After that, it all came up and sucessfully opened password file from old (~2012) version.

@mikelolasagasti : I'm more than happy to open a PR with the above patches, if you think they're any good. Please, let me know.

mikelolasagasti commented 4 years ago

@janvrany thanks for your contribution!

1. Add `@pyexecdir@` to `sys.path` in `revelation.py`. See [0001-Add-pyexecdir-to-Python-sys.path.patch.txt](https://github.com/mikelolasagasti/revelation/files/5200534/0001-Add-pyexecdir-to-Python-sys.path.patch.txt). See commit message for details.

I'll check this patch.

I usually test on /usr/local and things just work, haven't tested other paths, good to know this may fix the issue.

2. Changed makefiles to install `revelation.*` icon into different directory. See
   [0002-Install-Revelation-icon-in-Revelation-s-own-data-dir.patch.txt](https://github.com/mikelolasagasti/revelation/files/5200535/0002-Install-Revelation-icon-in-Revelation-s-own-data-dir.patch.txt). See commit message for details.

I've already done something similar to this because flaptak requirements:

https://github.com/mikelolasagasti/revelation/commit/7e89f08b305c95acb54956037c8b48909be6f872 https://github.com/mikelolasagasti/revelation/commit/3f5813a7dbc3d9a947a07c4ed420ca9679e9ac8f

But I need to doublecheck if your patch is also required or not.

3. Finally, manually copied `data/schemas/gschemas.compiled` to `${prefix}/share/revelation/schemas/gschemas.compiled`. Sorry, no patch for this yet, I'm not familiar enough with `automake` to understand how to add this to `make install`.

I'll check what options exist for gschema, as this is more tricky.

@mikelolasagasti : I'm more than happy to open a PR with the above patches, if you think they're any good. Please, let me know.

I can merge them maintaining your authorship, so in this case it won't be a hard requirement.

tpapp commented 4 years ago

@janvrany, that would be great.

janvrany commented 4 years ago

@mikelolasagasti

I can merge them...

Sure, feel free to merge them. Easier for me :-)

ronny-rentner commented 4 years ago

Hi, I have the same issue on Debian Buster.

$ /usr/local/bin/revelation 
Traceback (most recent call last):
  File "/usr/local/bin/revelation", line 30, in <module>
    from revelation import config, data, datahandler, dialog, entry, io, ui, util
ModuleNotFoundError: No module named 'revelation'

I can confirm that installing to /usr/local does not solve the problem.

ronny-rentner commented 4 years ago

PS: I can also not run it from the ./src dir after compilation.

$ ./src/revelation Traceback (most recent call last): File "./src/revelation", line 30, in <module> from revelation import config, data, datahandler, dialog, entry, io, ui, util File "/home/ronny/Projects/revelation/src/revelation.py", line 30, in <module> from revelation import config, data, datahandler, dialog, entry, io, ui, util ImportError: cannot import name 'config' from 'revelation' (/home/ronny/Projects/revelation/src/revelation.py)

mikelolasagasti commented 4 years ago

I can confirm that installing to /usr/local does not solve the problem.

This is because the way Debian/Ubuntu handle python's paths. For example, in a recent Ubuntu, the sys.path are set to:

$ python3 -c "import sys; print (sys.path)"
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/ubuntu/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']

$ sudo python3 -c "import sys; print (sys.path)"
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']

Instead, in Fedora:

$ python3 -c "import sys; print(sys.path)"
['', '/usr/lib64/python38.zip', '/usr/lib64/python3.8', '/usr/lib64/python3.8/lib-dynload', '/usr/local/lib64/python3.8/site-packages', '/usr/local/lib/python3.8/site-packages', '/usr/lib64/python3.8/site-packages', '/usr/lib/python3.8/site-packages']

So, installing in /usr/local works in Fedora because revelation gets installed in /usr/local/lib/python3.8/site-packages/revelation/, which is in the sys.path.

For Debian/Ubuntu best place would be $HOME/.local, and for that running ./configure --prefix=$HOME/.local would be enough.

Check other steps in https://github.com/mikelolasagasti/revelation/issues/29#issuecomment-694187176

mikelolasagasti commented 3 years ago

New steps to build described in README.md should avoid this issue.