azeam / powerupp

Simple GUI for UPP
GNU General Public License v3.0
81 stars 7 forks source link

ModuleNotFoundError: No module named 'upp' #13

Closed PNixx closed 4 years ago

PNixx commented 4 years ago

After click apply current I see in the terminal:

Values successfully loaded from pp table
Default file has 60 settings and there are 60 settings to write, not saving
Traceback (most recent call last):
  File "/home/nixx/.local/bin/upp", line 7, in <module>
    from upp.upp import main
ModuleNotFoundError: No module named 'upp'

Ubuntu 18.04.4

azeam commented 4 years ago

I believe this may be caused by initializing upp with Python2 (instead of Python3). Can you paste the output of
cat /home/nixx/.local/bin/upp

PNixx commented 4 years ago
$ cat /home/nixx/.local/bin/upp
#!/usr/bin/python3

# -*- coding: utf-8 -*-
import re
import sys

from upp.upp import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
PNixx commented 4 years ago

I install a new ubuntu and install

sudo apt install git build-essential libgtk-3-dev build-essential python3 python3-pip libpci-dev && pip3 install upp

before make powerupp. After make, run from terminal for see logs.

azeam commented 4 years ago

Thanks. Can you run upp from terminal (just type upp )?

Edit: if upp works, can you also paste the output of pip3 show upp?

PNixx commented 4 years ago
$ pip3 show upp
Name: upp
Version: 0.0.7
Summary: Uplift Power Play
Home-page: https://github.com/sibradzic/upp
Author: Samir Ibradžić
Author-email: None
License: UNKNOWN
Location: /home/nixx/.local/lib/python3.6/site-packages
Requires: click, python-registry
azeam commented 4 years ago

Pushed a new branch that I think should fix this, please try and let me know.

PNixx commented 4 years ago

No, I see same error

azeam commented 4 years ago

Ok, so likely not an issue with Python 2/3 (as was easily reproducible from my end, although not very logical) but probably an issue with missing library paths. Try this commit and see if it helps (not a fix, just need to understand what is going on).

PNixx commented 4 years ago

Yes, it works! Thanks

azeam commented 4 years ago

Do you have any thoughts on this @sibradzic ? For some reason that I have not fully understood yet, when starting upp via "bash -c ..." the PYTHONPATH, ie. the site-packages path where the upp library is located, is not available on a few systems (older Ubuntu?). The only way I seem to be able to set it up from powerupp is by immediately prepending the upp commands sent via Bash with PYTHONPATH=(each possible python version/site-packages) as in the test above, manually pre-setting the PYTHONPATH does not help as far as I can tell.

Do you see any better way to make sure the library path is found? Setting the path(s) in the upp bin, like import site site.addsitedir('/site-packages-path') seems to work as well, but this file is created automatically by pip and not adjustable afaik?

sibradzic commented 4 years ago

I think the main issue here is calling local user installed pip Python stuff with sudo. As I've stated in https://github.com/sibradzic/upp/blob/master/README.md, this weird workaround should make things work: sudo -E env "PATH=$PATH" upp --help. @PNixx, try calling out upp as I mention locally first to see if it helps, as this could be distro-specific.

azeam commented 4 years ago

@sibradzic Thanks, the env trick does not seem to help in this case though (in fact it causes this very issue for me). I'm running upp as user with sudo -u, but I think the sudo call may very well have something to do with it if invokes a new shell but without the users paths, this would explain why it is not possible to set up before the very last call. Maybe adding an -i switch will invoke the new user shell from sudo with proper paths? Can you try this @PNixx

PNixx commented 4 years ago

Yes, latest commit https://github.com/azeam/powerupp/commit/e2ae4f48bf0cfd1ae4945e7e88458850487ae59c works fine.

azeam commented 4 years ago

@PNixx perfect, adding this to main branch, thanks to both of you!