pyatv icon indicating copy to clipboard operation
pyatv copied to clipboard

Install Problem

Open Jon-G-Max opened this issue 1 year ago • 9 comments

What do you need help with?

Im sure this is a rookie error but do you have any idea why these errors are occurring? see errors below...

atvremote wizard 
Looking for devices...
Found the following devices:
    Name                       Model                Address
--  -------------------------  -------------------  -------------
 1  Grovers M1Max (2021)       MacBookPro18,2       192.168.1.151
 2  Dining Room                HomePod              192.168.1.180
 3  Basement                   Apple TV 4K (gen 3)  192.168.1.172
 4  MRX 540-42B9FA             MRX 540              192.168.1.183
 5  SONY XR-55A95K             XR-55A95K            192.168.1.191
 6  Living Room -Old Apple TV  Apple TV 4           192.168.1.153
 7  Family Room                Apple TV 4K (gen 3)  192.168.1.170
 8  Server 2024                Mac14,14             192.168.1.250
 9  Norma's MacBook Air        MacBookAir10,1       192.168.1.77
10  Server 2024                Mac14,14             192.168.1.232
Enter index of device to set up (q to quit): 7
Starting to set up Family Room
Starting to pair Protocol.Companion
Enter PIN on screen: 7308
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/__init__.py", line 71, in error_handler
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/protocols/companion/auth.py", line 99, in finish_pairing
    encrypted_data = self.srp.step3(name=display_name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/auth/hap_srp.py", line 202, in step3
    chacha = chacha20.Chacha20Cipher(self._session_key, self._session_key)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/chacha20.py", line 14, in __init__
    self._enc_out = ChaCha20Poly1305(out_key)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/chacha20poly1305_reuseable/__init__.py", line 82, in __init__
    if not AEAD_CIPHER_SUPPORTED(TEST_CIPHER):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 572, in aead_cipher_supported
    return aead._aead_cipher_supported(self, cipher)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/aead.py", line 22, in _aead_cipher_supported
    cipher_name = _evp_cipher_cipher_name(cipher)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/aead.py", line 66, in _evp_cipher_cipher_name
    assert isinstance(cipher, AESGCM)
AssertionError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 978, in _run_application
    return await cli_handler(loop)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 717, in cli_handler
    return await _exec_command(glob_cmds, args.command[0], print_result=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 945, in _exec_command
    value = await tmp(*args)
            ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 283, in wizard
    await self._wizard_pair(conf, service)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 355, in _wizard_pair
    await pairing.finish()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/protocols/companion/pairing.py", line 58, in finish
    await error_handler(
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/__init__.py", line 77, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError

>>> An error occurred, full stack trace above
2024-07-17 15:08:24 ERROR [asyncio]: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x104aa5f10>

Jon-G-Max avatar Jul 17 '24 19:07 Jon-G-Max

Based on this:

^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/aead.py", line 66, in _evp_cipher_cipher_name
    assert isinstance(cipher, AESGCM)
AssertionError

I assume OpenSSL is built without support AES GCM. This is the default installation of Python in macOS, right? Not installed via brew?

postlund avatar Jul 17 '24 20:07 postlund

This is macOS Sonoma 14.5. Not sure what comes preinstalled as default... Ran these commands.... Is there a URL you can suggest to install missing components?

MyHost ~ % openssl version
LibreSSL 3.3.6
MyHost ~ % openssl enc -help 2>&1 | grep gcm
 -aes-128-ecb              -aes-128-gcm              -aes-128-ofb             
 -aes-192-ctr              -aes-192-ecb              -aes-192-gcm             
 -aes-256-ctr              -aes-256-ecb              -aes-256-gcm             

Jon-G-Max avatar Jul 17 '24 20:07 Jon-G-Max

How did you install pyatv? I would recommend installing in a virtual environment. Looks to me like the cryptography library is quite old.

postlund avatar Jul 19 '24 17:07 postlund

Can you try to install from master and see if you notice any difference?

postlund avatar Jul 29 '24 18:07 postlund

I apologize but I'm really a newbie to open source, command line development. I have a stock MacBook Pro running Sonoma 14.5. Is there a step by step instruction on how to install from master ? My install used pip. I would really love to get this running but I don't want to waste anyone's time.

Jon-G-Max avatar Jul 29 '24 21:07 Jon-G-Max

I'm planning on making a new release quite soon, just waiting for some things to land. I'll let you know when it's ready, then you can just upgrade with pip.

postlund avatar Jul 31 '24 15:07 postlund

Any updates? running "pip install pyatv" followed by "atvremote wizard" still results in the same errors.

I'm trying to use a Mac to control an Apple TV GUI.

Enter index of device to set up (q to quit): 10
Starting to set up The Wall
Starting to pair Protocol.Companion
Enter PIN on screen: 6635
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/__init__.py", line 71, in error_handler
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/protocols/companion/auth.py", line 99, in finish_pairing
    encrypted_data = self.srp.step3(name=display_name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/auth/hap_srp.py", line 202, in step3
    chacha = chacha20.Chacha20Cipher(self._session_key, self._session_key)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/chacha20.py", line 14, in __init__
    self._enc_out = ChaCha20Poly1305(out_key)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/chacha20poly1305_reuseable/__init__.py", line 82, in __init__
    if not AEAD_CIPHER_SUPPORTED(TEST_CIPHER):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 572, in aead_cipher_supported
    return aead._aead_cipher_supported(self, cipher)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/aead.py", line 22, in _aead_cipher_supported
    cipher_name = _evp_cipher_cipher_name(cipher)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/aead.py", line 66, in _evp_cipher_cipher_name
    assert isinstance(cipher, AESGCM)
AssertionError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 978, in _run_application
    return await cli_handler(loop)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 717, in cli_handler
    return await _exec_command(glob_cmds, args.command[0], print_result=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 945, in _exec_command
    value = await tmp(*args)
            ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 283, in wizard
    await self._wizard_pair(conf, service)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 355, in _wizard_pair
    await pairing.finish()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/protocols/companion/pairing.py", line 58, in finish
    await error_handler(
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/__init__.py", line 77, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError

>>> An error occurred, full stack trace above
2024-09-05 14:29:12 ERROR [asyncio]: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x105e0c5f0>

Jon-G-Max avatar Sep 05 '24 18:09 Jon-G-Max

No progress I'm afraid. My recommendation is to instal home-brew and install python from there instead. That's what I do and it works.

postlund avatar Sep 06 '24 11:09 postlund

Hi,

I'm a user from de 0.6 version. I wanted to make a clean install on a new Mac and I have exactly the same problem. I'm on Sonoma 14.7 and my AppleTV is 18.1. I tried your last advice : install a virtual environment, install home-brew, then install python from there, and install pyatv. So I have Homebrew 4.4.3, pip 24.3.1, atvremote 0.15.1 in my virtual environment. When I perform the wizard, I have also :

` Traceback (most recent call last): File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/support/init.py", line 71, in error_handler return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/protocols/companion/auth.py", line 52, in start_pairing await self.protocol.start() File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/protocols/companion/protocol.py", line 100, in start await self.connection.connect() File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/protocols/companion/connection.py", line 81, in connect await self.loop.create_connection(lambda: self, self.host, self.port) File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1122, in create_connection raise exceptions[0] File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1104, in create_connection sock = await self._connect_sock( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1007, in _connect_sock await self.sock_connect(sock, address) File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/selector_events.py", line 651, in sock_connect return await fut ^^^^^^^^^ File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/selector_events.py", line 691, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 51] Connect call failed ('192.168.0.40', 49153)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 997, in _run_application return await cli_handler(loop) ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 720, in cli_handler return await _exec_command(glob_cmds, args.command[0], print_result=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 964, in _exec_command value = await tmp(*args) ^^^^^^^^^^^^^^^^ File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 286, in wizard await self._wizard_pair(conf, service) File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 341, in _wizard_pair await pairing.begin() File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/protocols/companion/pairing.py", line 48, in begin await error_handler( File "/Users/jeremiehalfon/pyatv_venv/lib/python3.12/site-packages/pyatv/support/init.py", line 73, in error_handler raise exceptions.ConnectionFailedError(str(ex)) from ex pyatv.exceptions.ConnectionFailedError: [Errno 51] Connect call failed ('192.168.0.40', 49153)

An error occurred, full stack trace above 2024-10-29 20:07:15 ERROR [asyncio]: Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x103508e60>

`

Do you have any idea or it's a problem with Sonoma ? or tvOS 18 ?

Thanks and no rush,

Best regards.

Edit 2 : may be a clue. I tried the exact same procedure on a Mac running 14.6.1, and there were no issues with the installation or pairing with the wizard. I then copied the pyatv_venv folder directly to the Mac running 14.7, and the wizard successfully paired with this Mac as well.

I also tried creating a new pyatv_venv_beta directly on the same Mac running 14.7 and repeated the exact same steps. However, I encountered an issue with the installation of pyatv. Although the installation was reported as successful, when I use atvremote, I experience this problem: : "(pyatv_venv_test) jeremiehalfon@MacBook-Air-M1-de-Jeremie ~ % atvremote --version Traceback (most recent call last): File "/Users/jeremiehalfon/pyatv_venv_test/bin/atvremote", line 5, in from pyatv.scripts.atvremote import main File "/Users/jeremiehalfon/pyatv_venv_test/lib/python3.13/site-packages/pyatv/init.py", line 26, in from pyatv.protocols import PROTOCOLS File "/Users/jeremiehalfon/pyatv_venv_test/lib/python3.13/site-packages/pyatv/protocols/init.py", line 10, in from pyatv.protocols import airplay as airplay_proto File "/Users/jeremiehalfon/pyatv_venv_test/lib/python3.13/site-packages/pyatv/protocols/airplay/init.py", line 29, in from pyatv.protocols.airplay.ap2_session import AP2Session File "/Users/jeremiehalfon/pyatv_venv_test/lib/python3.13/site-packages/pyatv/protocols/airplay/ap2_session.py", line 23, in from pyatv.support.rtsp import RtspSession File "/Users/jeremiehalfon/pyatv_venv_test/lib/python3.13/site-packages/pyatv/support/rtsp.py", line 18, in from pyatv.support.metadata import MediaMetadata File "/Users/jeremiehalfon/pyatv_venv_test/lib/python3.13/site-packages/pyatv/support/metadata.py", line 7, in from mediafile import MediaFile File "/Users/jeremiehalfon/pyatv_venv_test/lib/python3.13/site-packages/mediafile.py", line 52, in import imghdr ModuleNotFoundError: No module named 'imghdr'"

May be this is normal, and we can't install atvremote in two different venv.

oculist37 avatar Oct 29 '24 19:10 oculist37