rbreaves / kinto

Mac-style shortcut keys for Linux & Windows.
http://kinto.sh
GNU General Public License v2.0
4.46k stars 214 forks source link

ModuleNotFoundError: No module named 'gi' #388

Closed mildfuzz closed 3 years ago

mildfuzz commented 3 years ago

When running ~/.config/kinto/gui/kinto-gui.py I run into this:

~/.config/kinto/gui/kinto-gui.py
Traceback (most recent call last):
  File "~/.config/kinto/gui/kinto-gui.py", line 3, in <module>
    import gi,os,time,fcntl,argparse,re
ModuleNotFoundError: No module named 'gi'

Expected behaviour A clear and concise description of what you expected to happen.

Install Type: Bare Metal Distro: Ubuntu 20.04.2 LTS DE: Gnome Branch: master Commit: 50d53ba

rbreaves commented 3 years ago

sudo apt-get install python3-gi

or

pip install vext

pip install vext.gi

https://askubuntu.com/questions/80448/what-would-cause-the-gi-module-to-be-missing-from-python

Let me know if that works, I can add it as a dependency to check and install, but it hadn't came up in my testing.

mildfuzz commented 3 years ago

none of that seems to work. Could it related to I am on python3? Everything seems to be aliased with a 3 in my system (python3, pip3)

My python knowledge isn't amazing, so I am of limited help

On Mon, Feb 8, 2021 at 6:51 PM Ben Reaves notifications@github.com wrote:

sudo apt-get install python3-gi

or

pip install vext.gi``` https://askubuntu.com/questions/80448/what-would-cause-the-gi-module-to-be-missing-from-python

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rbreaves/kinto/issues/388#issuecomment-775363754, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABQAYLEL6ERQLZOVCR7BGTS6AXCRANCNFSM4XI7UXQQ .

-- John

follow me on twitter @mildfuzz

http://mildfuzz.com 07800500608

rbreaves commented 3 years ago

I’d be more concerned that you’re using python2 than python3 or aliased 3. Python3 is what you want.

could try pip3 or sudo pip3..

mildfuzz commented 3 years ago

yeah, that is what I did, no darts

mildfuzz commented 3 years ago

I tried running the init script with sudo to see if that helped

sudo ~/.config/kinto/gui/kinto-gui.py

/home/john/.config/kinto/gui/kinto-gui.py:51: DeprecationWarning: Gtk.Misc.set_alignment is deprecated
  label.set_alignment(1, 0)
Traceback (most recent call last):
  File "/home/john/.config/kinto/gui/kinto-gui.py", line 1432, in <module>
    win = MyWindow()
  File "/home/john/.config/kinto/gui/kinto-gui.py", line 91, in __init__
    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, width, height, preserve_aspect_ratio)
gi.repository.GLib.Error: g-file-error-quark: Failed to open file “/root/.config/kinto/kinto-color.svg”: No such file or directory (4)
ChrisBit commented 3 years ago

I tried running the init script with sudo to see if that helped

sudo ~/.config/kinto/gui/kinto-gui.py

/home/john/.config/kinto/gui/kinto-gui.py:51: DeprecationWarning: Gtk.Misc.set_alignment is deprecated
  label.set_alignment(1, 0)
Traceback (most recent call last):
  File "/home/john/.config/kinto/gui/kinto-gui.py", line 1432, in <module>
    win = MyWindow()
  File "/home/john/.config/kinto/gui/kinto-gui.py", line 91, in __init__
    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, width, height, preserve_aspect_ratio)
gi.repository.GLib.Error: g-file-error-quark: Failed to open file “/root/.config/kinto/kinto-color.svg”: No such file or directory (4)

I have the same base issue.

The error here comes from that kinto-gui.py resolves home directory to /root/ (since we are running the script with sudo) while the kinto assets it wants to load are actually in the users home directory. I tested hardcoding a global variable named "homedir" in the script to my actual home directory while running the script as sudo and that made the script run as expected.

ChrisBit commented 3 years ago

I managed to get the script working without sudo tho.

I have homebrew (https://brew.sh) installed on my machine. And a package I have installed via brew is dependent on python3 and therefore had installed it's own copy of it. By running brew uninstall --ignore-dependencies python3 I was able to get kinto working again.

So brew, and potentially other package managers, could interfere with the python3 installed with apt and cause this issue.

rbreaves commented 3 years ago

Thanks for figuring that out @ChrisBit - I can work with that!

mildfuzz commented 3 years ago

I bought a new keyboard, so now probably won't use this.

mihirsamdarshi commented 3 years ago

I am having the same issue on bare-metal 20.04 LTS, but I don't have homebrew installed on my machine. Any way that I can help debug this?

I also tried pip3 install vext vext.gi and sudo pip3 install vext vext.gi. My python 3 install is currently at 3.8.5, installed using apt.

rbreaves commented 3 years ago

@mihirsamdarshi Ubuntu 20.04? I will create fresh VM and start doing some testing, I heard the python pip3 package name might have changed any ways.

albertskog commented 3 years ago

I'm using pyenv[1] and also ran into this issue. Not sure if it is pyenv's fault or not but at least I was able to fix it by running root's Python like this:

$(sudo which python3) ~/.config/kinto/gui/kinto-gui.py

Pyenv inserts shims to let you have a different Python environment in every folder so I suppose this was caused by the installer using sudo(?)

➜  ~ which python                                          
/home/albert/.pyenv/shims/python
➜  ~ which python3
/home/albert/.pyenv/shims/python3
➜  ~ sudo which python

➜  ~ sudo which python3
/usr/bin/python3

[1] https://github.com/pyenv/pyenv

mandarvaze commented 3 years ago

I had same problem as @ChrisBit The latest version has homedir as well as os.environ['HOME'] I had to hardcode both these variables to my home directory.

Yes, it worked flawlessly.

Thanks @rbreaves for this awesome software.

rbreaves commented 3 years ago

Hmmm.. not sure why there’d be issues w/ the home dir not pulling in. Which distro are you on? @mandarvaze

Also I believe I’ll be closing this thread in favor of this one as I believe they’re the same but the suggested fix is more direct & doesn’t involve installing additional packages, brew or sudo.

https://github.com/rbreaves/kinto/issues/529

mandarvaze commented 3 years ago

@rbreaves I'm on Ubuntu Budgie 21.04 I'm using pyenv (Like @albertskog ) - which lead to other errors, but I fixed those.

I kept getting Failed to open file “/root/.config/kinto/kinto-color.svg”: No such file or directory The file is in my home directory path, not under /root/

rbreaves commented 3 years ago

The setup.py was really not intended to be ran with sudo and I suspect that is why you get that error. I know of no other reason on why it would drop your local env variables and try and setup in the root user. There are certain commands that run on the sudo level during setup but the entire setup itself should not be running under sudo. @mandarvaze There may also be a sudo parameter you could use to retain your local user env variables, sudo -i -u username ./setup.py I think might keep local env variables? If you really think you need to run setup under sudo.

I will spin up a 21.04 VM of Ubuntu Budgie this weekend and see what's going on though, if I need to make an update to the installer I will do so. I just recently upgraded my Budgie 20.04 to 21.04 (and going forward I will be sticking with more recent builds vs the LTS ones for desktop use).

mandarvaze commented 3 years ago

@rbreaves The error is not from setup.py - It is from ~/.config/kinto/gui/kinto-gui.py

I tried the same again. uninstalled (and then installed) using new method. (So I did not have to run setup.py)

This time, I got the error from the title of this issue No module named 'gi' - But this is same as @albertskog Same solution - i.e. use /usr/bin/python3 ~/.config/kinto/gui/kinto-gui.py resolved the issue - cause I'm also using pyenv (as stated earlier)

Right now - I have no open issues related to using kinto. I just added the details for anyone else coming here looking for clues/solutions/ideas.

rbreaves commented 3 years ago

Yea I might ought to test w/ pyenv, just surprised it’d use a root path I guess, but makes sense on why it’s fail running via that method. And yea I the closing was more directed at others on this thread so they’d know it’s not being ignored. A future fix will be coming.

alex-schaaf commented 3 years ago

I'm also using pyenv on my system and was unable to simply run sudo apt-get install python-imaging after the setup completed, but the GUI did never open. Running /usr/bin/python3 ~/.config/kinto/gui/kinto-gui.py would result in the error ModuleNotFoundError: No module named 'PIL'. I was able to get it working by /usr/bin/python3 -m pip install image, which aparrently installs the missing PIL dependency needed.

fffx commented 2 years ago

I'm using homebrew on Linux mint, found out I need to unlink homebrew installed python3

brew unlink python3
stevenlovegrove commented 8 months ago

I didn't want to mess with my python versions and managed to get this working on Ubuntu 22.04 with:

sudo apt install libgirepository1.0-dev
pip install PyGObject