petro-kushchak / homebridge-homepod-radio

MIT License
36 stars 2 forks source link

No module named 'pyatv' #35

Open sohnkarlsruhe opened 1 year ago

sohnkarlsruhe commented 1 year ago

get this error [17.3.2023, 10:49:11] Error: Command failed: atvremote --id 50xxxxxxF1 stream_file=/home/homebridge/garageoffen.mp3 Traceback (most recent call last): File "/usr/local/bin/atvremote", line 5, in from pyatv.scripts.atvremote import main ModuleNotFoundError: No module named 'pyatv'

atvremote scan works i use stable and alpha version homebridge crashed when i play a mp3 file

TheeNawMan commented 1 year ago

Are you using ozone/homebridge container?

If so I fixed it but adding the following to my startup.sh which you should be able to modify from homebridge terminal

apt update
apt install -y python3 python3-pip ffmpeg
pip3 install pyatv
ln -s /home/homebridge./local/bin/atvremote /usr/local/bin/atvremote
sohnkarlsruhe commented 1 year ago

No containers. All packages are already installed und linked

petro-kushchak commented 1 year ago

Hi - this might be related to default python version, plugin uses python3 and in your case pyatv might be installed under different version of python... Try to reinstall pyatv with :

pip3 install pyatv

sohnkarlsruhe commented 1 year ago

it is not working, here is the complete log

[20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton Switch] SET ON: true [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomePod Radio] Stopping playback - received stop request from HomepodButton [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomePod Radio] Trying to stop stopped process! [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomePod Radio] Skipped storing state [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] Started hearbeat undefined [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] spawn streaming: 2351 [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] Started file streaming /home/homebridge/garrage.mp3 [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] streaming data: Traceback (most recent call last): File "/var/lib/homebridge/node_modules/@petro-kushchak/homebridge-homepod-radio/dist/stream.py", line 20, in

[20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] streaming data: import pyatv ModuleNotFoundError: No module named 'pyatv'

[20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] streaming exit: code 1 signal null [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] Killing process: streaming: 2351 [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] Cleared hearbeat undefined - stop requested [20.3.2023, 13:24:54] [HomepodRadioPlatform] [HomepodButton] Error while trying to stop: Error: Command failed: kill -9 2351 /bin/sh: 1: kill: No such process

TheeNawMan commented 1 year ago

Are you using a virtual environment to run pyatv?

Can you explain the OS you are using what packages you installed... Maybe if you have a link to a guide you followed we can assist as well.

sohnkarlsruhe commented 1 year ago

Raspberry Pi 4 with the Image from homebridge-raspbian-image

sohnkarlsruhe commented 1 year ago

Homebridge runs under user homebridge. I change this to pi and now it works.

aboulfad commented 1 year ago

I've been scratching my head for hours, could it be a path issue for user homebridge ? even setting full permissions on .local where pyatv is installed doesn't make a difference. How does one change homebridge to run as user pi ?

Here's the error details I get: `Error: Command failed: atvremote -s ab:cd:ef:ef --scan-protocols raop stop set_volume=50 stream_file=/home/pi/media/washflood.mp3 Traceback (most recent call last): File "/usr/local/bin/atvremote", line 5, in from pyatv.scripts.atvremote import main

ModuleNotFoundError: No module named 'pyatv at ChildProcess.exithandler (node:child_process:419:12) at ChildProcess.emit (node:events:513:28) at maybeClose (node:internal/child_process:1091:16) at Socket. (node:internal/child_process:449:11) at Socket.emit (node:events:513:28) at Pipe. (node:net:322:12)`

aboulfad commented 1 year ago

It did turn out to be an install path issue. For some reason when executing on a rpios (bullseye) pip3 install pyatv, pip installs it in ~/.local which is not found by homebridge service running as user homebridge. What worked for me is to install pyatv globally using sudo -H pip3 install pyatv.

HTH