DevilXD / TwitchDropsMiner

An app that allows you to AFK mine timed Twitch drops, with automatic drop claiming and channel switching.
MIT License
1.56k stars 159 forks source link

[Bug] Error while starting with last update on RaspberryPi #221

Open kevingrillet opened 1 year ago

kevingrillet commented 1 year ago

I've just pull the last update of the project, then updated the packages & run, but it's not working :/

Hardware

Model       : Raspberry Pi 4 Model B Rev 1.1

Running on Raspbian 32 bits, up to date.

Update

    cd "$HOME/Downloads/TwitchDropsMiner/" || exit

    # Update
    git pull --ff-only

    # Update requirements
    source ./env/bin/activate
    pip install -r requirements.txt

Output:

pi@raspberrypi:~/Documents $ ./tdm.sh -u
remote: Enumerating objects: 64, done.
remote: Counting objects: 100% (64/64), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 64 (delta 40), reused 55 (delta 31), pack-reused 0
Unpacking objects: 100% (64/64), 20.61 KiB | 180.00 KiB/s, done.
From https://github.com/DevilXD/TwitchDropsMiner
   4664a9d..3fa9568  master     -> origin/master
 + 977f997...e15e593 linux      -> origin/linux  (forced update)
Updating 4664a9d..3fa9568
Fast-forward
 .github/workflows/ci.yml | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 README.md                | 14 ++++++++++++++
 build.spec               | 41 ++++++++++++++++++++++++++++-----------
 gui.py                   | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
 main.py                  |  4 ++++
 requirements.txt         |  5 ++++-
 utils.py                 | 30 ++++++++++++++++++++++++++++-
 7 files changed, 231 insertions(+), 59 deletions(-)
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pystray@ git+https://github.com/moses-palmer/pystray.git@903836104f8b1a2979f4fa5a333870ef7b075992
  Cloning https://github.com/moses-palmer/pystray.git (to revision 903836104f8b1a2979f4fa5a333870ef7b075992) to /tmp/pip-install-vrn36e1g/pystray_255a514090c2474e9d6e868390270afd
  Running command git clone -q https://github.com/moses-palmer/pystray.git /tmp/pip-install-vrn36e1g/pystray_255a514090c2474e9d6e868390270afd
  Running command git rev-parse -q --verify 'sha^903836104f8b1a2979f4fa5a333870ef7b075992'
  Running command git fetch -q https://github.com/moses-palmer/pystray.git 903836104f8b1a2979f4fa5a333870ef7b075992
Ignoring pywin32: markers 'sys_platform == "win32"' don't match your environment
Ignoring truststore: markers 'sys_platform == "linux" and python_version >= "3.10"' don't match your environment
Requirement already satisfied: aiohttp<4.0,>2.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (3.8.4)
Requirement already satisfied: Pillow in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (9.4.0)
Collecting PyGObject
  Downloading https://www.piwheels.org/simple/pygobject/PyGObject-3.44.1-cp39-cp39-linux_armv7l.whl (729 kB)
     |████████████████████████████████| 729 kB 1.1 MB/s 
Requirement already satisfied: six in ./env/lib/python3.9/site-packages (from pystray@ git+https://github.com/moses-palmer/pystray.git@903836104f8b1a2979f4fa5a333870ef7b075992->-r requirements.txt (line 4)) (1.16.0)
Requirement already satisfied: python-xlib>=0.17 in ./env/lib/python3.9/site-packages (from pystray@ git+https://github.com/moses-palmer/pystray.git@903836104f8b1a2979f4fa5a333870ef7b075992->-r requirements.txt (line 4)) (0.33)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (3.1.0)
Requirement already satisfied: aiosignal>=1.1.2 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (1.3.1)
Requirement already satisfied: attrs>=17.3.0 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (22.2.0)
Requirement already satisfied: yarl<2.0,>=1.0 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (1.8.2)
Requirement already satisfied: frozenlist>=1.1.1 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (1.3.3)
Requirement already satisfied: multidict<7.0,>=4.5 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (6.0.4)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (4.0.2)
Requirement already satisfied: idna>=2.0 in ./env/lib/python3.9/site-packages (from yarl<2.0,>=1.0->aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (3.4)
Collecting pycairo>=1.16.0
  Downloading https://www.piwheels.org/simple/pycairo/pycairo-1.23.0-cp39-cp39-linux_armv7l.whl (296 kB)
     |████████████████████████████████| 296 kB 2.6 MB/s 
Installing collected packages: pycairo, PyGObject
Successfully installed PyGObject-3.44.1 pycairo-1.23.0

Run

    cd "$HOME/Downloads/TwitchDropsMiner/" || exit
    source ./env/bin/activate
    python main.py --log

Output

pi@raspberrypi:~/Documents $ ./tdm.sh -r
Traceback (most recent call last):
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/_appindicator.py", line 23, in <module>
    gi.require_version('AppIndicator3', '0.1')
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace AppIndicator3 not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Downloads/TwitchDropsMiner/main.py", line 25, in <module>
    from twitch import Twitch
  File "/home/pi/Downloads/TwitchDropsMiner/twitch.py", line 39, in <module>
    from gui import GUIManager
  File "/home/pi/Downloads/TwitchDropsMiner/gui.py", line 22, in <module>
    import pystray
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/__init__.py", line 64, in <module>
    Icon = backend().Icon
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/__init__.py", line 56, in backend
    return candidate()
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/__init__.py", line 28, in appindicator
    from . import _appindicator as backend; return backend
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/_appindicator.py", line 26, in <module>
    gi.require_version('AyatanaAppIndicator3', '0.1')
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace AyatanaAppIndicator3 not available
guihkx commented 1 year ago

You have a few options:

guihkx commented 1 year ago

P.S.: This is not a bug.

Installing the AppIndicator libraries on Linux is now "required" (unless you apply the second or third workaround I mentioned in my previous post), because after the addition of PyGObject as a dependency (which was done for better tray icon support), pystray detects it and defaults to the appindicator backend, where before it'd just choose gtk or whatever.

And because the Linux binary we are distributing through the CI (AMD64 only, unfortunately) already includes everything, it didn't cross my mind to mention this in the README, but we probably should.

kevingrillet commented 1 year ago

What makes me think it's a bug is that it's not written in the README / wiki ;)

https://github.com/DevilXD/TwitchDropsMiner/blob/3fa95687d7dab6707bed3fdd74cccc9f483535fc/README.md?plain=1#L46-L53

But yep, I should migrate my RaspberryPi to 64bit too 😄

kevingrillet commented 1 year ago

I did try but still not working :(

tdm.sh ```sh #!/bin/bash apt_install() { sudo apt-get install -y libappindicator3-1 } exe() { cd "$HOME/Downloads/TwitchDropsMiner/" || exit # Create .exe pip install pyinstaller pyinstaller build.spec } run() { cd "$HOME/Downloads/TwitchDropsMiner/" || exit source ./env/bin/activate python main.py --log } update() { cd "$HOME/Downloads/TwitchDropsMiner/" || exit # Update git pull --ff-only # Update requirements source ./env/bin/activate pip install -r requirements.txt } show_help() { Color_Off="\033[0m" # Text Reset IYellow="\033[0;93m" # Yellow ICyan="\033[0;96m" # Cyan echo -e "${Color_Off}USAGE: ${IYellow}tdm.sh ${ICyan}[OPTIONS]${Color_Off}" echo echo -e "OPTIONS" echo -e " ${ICyan}-a${Color_Off}" echo -e " Install apt packages for Linux." echo -e " ${ICyan}-e${Color_Off}" echo -e " Compile exe for Windows." echo -e " ${ICyan}-h${Color_Off}" echo -e " Show help." echo -e " ${ICyan}-r${Color_Off}" echo -e " Run from sources." echo -e " ${ICyan}-u${Color_Off}" echo -e " Update sources & pip packages." } if [ -z "$1" ]; then run exit 0 fi while getopts ":aehru" opt; do case $opt in a) apt_install ;; e) exe ;; h) show_help ;; r) run ;; u) update ;; \?) echo "$OPTARG : Invalid option" exit 1 ;; esac done exit 0 ```
pi@raspberrypi:~/Documents $ sudo apt-get install -y libappindicator3-1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libappindicator3-1 is already the newest version (0.4.92-8).
The following packages were automatically installed and are no longer required:
  golang-1.15 golang-1.15-doc golang-1.15-go golang-1.15-src golang-doc golang-go golang-src
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@raspberrypi:~/Documents $ ./tdm.sh -r
Traceback (most recent call last):
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/_appindicator.py", line 23, in <module>
    gi.require_version('AppIndicator3', '0.1')
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace AppIndicator3 not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Downloads/TwitchDropsMiner/main.py", line 29, in <module>
    from twitch import Twitch
  File "/home/pi/Downloads/TwitchDropsMiner/twitch.py", line 39, in <module>
    from gui import GUIManager
  File "/home/pi/Downloads/TwitchDropsMiner/gui.py", line 21, in <module>
    import pystray
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/__init__.py", line 64, in <module>
    Icon = backend().Icon
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/__init__.py", line 56, in backend
    return candidate()
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/__init__.py", line 28, in appindicator
    from . import _appindicator as backend; return backend
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/pystray/_appindicator.py", line 26, in <module>
    gi.require_version('AyatanaAppIndicator3', '0.1')
  File "/home/pi/Downloads/TwitchDropsMiner/env/lib/python3.9/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace AyatanaAppIndicator3 not available
miroslav-suvada commented 1 year ago

@kevingrillet I had to install these additional packages on Ubuntu to make it work

sudo apt install gir1.2-appindicator3-0.1 libcairo2-dev libgirepository1.0-dev pkg-config

kevingrillet commented 1 year ago

@miroslav-suvada Ty, it works!

tdm.sh ```sh #!/bin/bash apt_install() { # sudo apt-get install -y libgtk-3-dev # sudo apt-get install -y libappindicator3-1 sudo apt-get install -y gir1.2-appindicator3-0.1 libcairo2-dev libgirepository1.0-dev pkg-config } exe() { cd "$HOME/Downloads/TwitchDropsMiner/" || exit # Create .exe pip install pyinstaller pyinstaller build.spec } run() { cd "$HOME/Downloads/TwitchDropsMiner/" || exit # PYSTRAY_BACKEND=gtk source ./env/bin/activate python main.py --log } update() { cd "$HOME/Downloads/TwitchDropsMiner/" || exit # Update git pull --ff-only # Update requirements source ./env/bin/activate pip install -r requirements.txt } show_help() { Color_Off="\033[0m" # Text Reset IYellow="\033[0;93m" # Yellow ICyan="\033[0;96m" # Cyan echo -e "${Color_Off}USAGE: ${IYellow}tdm.sh ${ICyan}[OPTIONS]${Color_Off}" echo echo -e "OPTIONS" echo -e " ${ICyan}-a${Color_Off}" echo -e " Install apt packages for Linux." echo -e " ${ICyan}-e${Color_Off}" echo -e " Compile exe for Windows." echo -e " ${ICyan}-h${Color_Off}" echo -e " Show help." echo -e " ${ICyan}-r${Color_Off}" echo -e " Run from sources." echo -e " ${ICyan}-u${Color_Off}" echo -e " Update sources & pip packages." } if [ -z "$1" ]; then run exit 0 fi while getopts ":aehru" opt; do case $opt in a) apt_install ;; e) exe ;; h) show_help ;; r) run ;; u) update ;; \?) echo "$OPTARG : Invalid option" exit 1 ;; esac done exit 0 ```
pi@raspberrypi:~/Documents $ ./tdm.sh -aur
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
gir1.2-appindicator3-0.1 is already the newest version (0.4.92-8).
libgirepository1.0-dev is already the newest version (1.66.1-1+b1).
pkg-config is already the newest version (0.29.2-1).
libcairo2-dev is already the newest version (1.16.0-5+rpt1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Already up to date.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pystray@ git+https://github.com/moses-palmer/pystray.git@903836104f8b1a2979f4fa5a333870ef7b075992
  Cloning https://github.com/moses-palmer/pystray.git (to revision 903836104f8b1a2979f4fa5a333870ef7b075992) to /tmp/pip-install-xg1_wrl9/pystray_333945fa934f4da78ebd5921076bbc34
  Running command git clone -q https://github.com/moses-palmer/pystray.git /tmp/pip-install-xg1_wrl9/pystray_333945fa934f4da78ebd5921076bbc34
  Running command git rev-parse -q --verify 'sha^903836104f8b1a2979f4fa5a333870ef7b075992'
  Running command git fetch -q https://github.com/moses-palmer/pystray.git 903836104f8b1a2979f4fa5a333870ef7b075992
Ignoring pywin32: markers 'sys_platform == "win32"' don't match your environment
Ignoring truststore: markers 'sys_platform == "linux" and python_version >= "3.10"' don't match your environment
Requirement already satisfied: aiohttp<4.0,>2.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (3.8.4)
Requirement already satisfied: Pillow in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (9.4.0)
Requirement already satisfied: PyGObject in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 5)) (3.44.1)
Requirement already satisfied: six in ./env/lib/python3.9/site-packages (from pystray@ git+https://github.com/moses-palmer/pystray.git@903836104f8b1a2979f4fa5a333870ef7b075992->-r requirements.txt (line 4)) (1.16.0)
Requirement already satisfied: python-xlib>=0.17 in ./env/lib/python3.9/site-packages (from pystray@ git+https://github.com/moses-palmer/pystray.git@903836104f8b1a2979f4fa5a333870ef7b075992->-r requirements.txt (line 4)) (0.33)
Requirement already satisfied: frozenlist>=1.1.1 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (1.3.3)
Requirement already satisfied: yarl<2.0,>=1.0 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (1.8.2)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (3.1.0)
Requirement already satisfied: aiosignal>=1.1.2 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (1.3.1)
Requirement already satisfied: multidict<7.0,>=4.5 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (6.0.4)
Requirement already satisfied: attrs>=17.3.0 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (22.2.0)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in ./env/lib/python3.9/site-packages (from aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (4.0.2)
Requirement already satisfied: idna>=2.0 in ./env/lib/python3.9/site-packages (from yarl<2.0,>=1.0->aiohttp<4.0,>2.0->-r requirements.txt (line 1)) (3.4)
Requirement already satisfied: pycairo>=1.16.0 in ./env/lib/python3.9/site-packages (from PyGObject->-r requirements.txt (line 5)) (1.23.0)
bmbeverst commented 10 months ago

@DevilXD thanks for this great tool! I don't like running my desktop 24/7 so installed this on a Pi. Running DietPi from a 4 GB SD card on a Raspberry Pi rev2 B.

Below are the upgraded scripts, also added this comment's code. Would like to have this in one session with two windows.

Since everything is now in tmux you have to run tmux a and can get a preview of all the windows by pressing Ctrl+b w and detach with Ctrl+b d. This does login, but that is only as far as I have tested.

tmux-tdm.sh
``` tmux new-session -d -s Xvfb tmux send-keys -t Xvfb 'Xvfb :99 -screen 0 1x2x8' Enter tmux new-session -d -s tdm tmux send-keys -t tdm 'cd ~/TwitchDropsMiner;source ./env/bin/activate;export DISPLAY=:99;./env/bin/python main.py --log' Enter ```
tdm.sh
``` #!/bin/bash apt_install() { # sudo apt-get install -y libgtk-3-dev # sudo apt-get install -y libappindicator3-1 sudo apt-get install -y gir1.2-appindicator3-0.1 libcairo2-dev libgirepository1.0-dev pkg-config libopenjp2-7 xauth tmux python3-venv python3 python3-tk Xvfb } exe() { cd "$HOME/TwitchDropsMiner/" || exit # Create .exe pip install pyinstaller pyinstaller build.spec } run() { cd "$HOME/TwitchDropsMiner/" || exit ./tmux-tdm.sh echo "Tmux sessions running:" tmux ls } update() { cd "$HOME/TwitchDropsMiner/" || exit # Update git pull --ff-only # Update requirements source ./env/bin/activate pip install -r requirements.txt } show_help() { Color_Off="\033[0m" # Text Reset IYellow="\033[0;93m" # Yellow ICyan="\033[0;96m" # Cyan echo -e "${Color_Off}USAGE: ${IYellow}tdm.sh ${ICyan}[OPTIONS]${Color_Off}" echo echo -e "OPTIONS" echo -e " ${ICyan}-a${Color_Off}" echo -e " Install apt packages for Linux." echo -e " ${ICyan}-e${Color_Off}" echo -e " Compile exe for Windows." echo -e " ${ICyan}-h${Color_Off}" echo -e " Show help." echo -e " ${ICyan}-r${Color_Off}" echo -e " Run from sources." echo -e " ${ICyan}-u${Color_Off}" echo -e " Update sources & pip packages." } if [ -z "$1" ]; then run exit 0 fi while getopts ":aehru" opt; do case $opt in a) apt_install ;; e) exe ;; h) show_help ;; r) run ;; u) update ;; \?) echo "$OPTARG : Invalid option" exit 1 ;; esac done exit 0 ```
CloudEater11 commented 5 months ago

I was having the same problem on my raspberry pi 4b with 'AppIndicator3 not available', but for some reason 'apt-get install gir1.2-appindicator3-0' was not able to find the package, from what I see online gir1.2 is outdated. I was able to circumvent the issue by building from source and running in a venv following this guide. Now I get the same issue when starting with python3 main.py, however by starting with PYSTRAY_BACKEND=gtk python3 main.py, as mentioned here, it works perfectly!

GoesInCircles commented 3 months ago

@DevilXD thanks for this great tool! I don't like running my desktop 24/7 so installed this on a Pi. Running DietPi from a 4 GB SD card on a Raspberry Pi rev2 B.

Below are the upgraded scripts...

Hi, sorry to resurrect like this, are you still somehow active in raspi TDM?

I tried script from your comment with new TDM by Win20k (which fixed drop change done by twitch) https://github.com/Windows200000/TwitchDropsMiner-updated/releases, but without success.

I would really like to run this on raspi and not keeping my main pc up. If you could look into it and do little walkthru on how to do it properly, it will be epic.

Thanks