Fairly desperate.... unable to use PIO remote suddenly

I’ve been using PIO remote fairly heavily and have become dependent on it for my project.
I’ve got an M3 mac air, running Sonoma 14.4.
I’ve been running the PIO IDE using BuiltinCore option. However I also had installed PIO using the install script.

I was getting a weird bug using pio run, and pro remote run where it redownloaded all the libs. benign but added time to my compilation.
I followed advice on PIO that having multiple PIO versions may cause this so uninstalled it as per the instructions using pip unsintall… the IDE then installed core automatically…

PIO run works…

PIO remove does not

ImportError: Traceback (most recent call last):
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/platformio/__main__.py", line 103, in main
    cli()  # pylint: disable=no-value-for-parameter
    ^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/platformio/cli.py", line 85, in invoke
    return super().invoke(ctx)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/click/decorators.py", line 45, in new_func
    return f(get_current_context().obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/platformio/remote/cli.py", line 265, in device_list
    from platformio.remote.client.device_list import DeviceListClient
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/platformio/remote/client/device_list.py", line 19, in <module>
    from platformio.remote.client.base import RemoteClientBase
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/platformio/remote/client/base.py", line 30, in <module>
    from platformio.remote.factory.ssl import SSLContextFactory
  File "/Users/amelvin/.platformio/penv/lib/python3.11/site-packages/platformio/remote/factory/ssl.py", line 16, in <module>
    from OpenSSL import SSL  # pylint: disable=import-error
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/amelvin/.platformio/packages/contrib-pioremote/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import SSL, crypto
  File "/Users/amelvin/.platformio/packages/contrib-pioremote/OpenSSL/SSL.py", line 11, in <module>
    from OpenSSL._util import (
  File "/Users/amelvin/.platformio/packages/contrib-pioremote/OpenSSL/_util.py", line 6, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "/Users/amelvin/.platformio/packages/contrib-pioremote/cryptography/hazmat/bindings/openssl/binding.py", line 15, in <module>
    from cryptography.exceptions import InternalError
  File "/Users/amelvin/.platformio/packages/contrib-pioremote/cryptography/exceptions.py", line 9, in <module>
    from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
ImportError: dlopen(/Users/amelvin/.platformio/packages/contrib-pioremote/_cffi_backend.cpython-311-darwin.so, 0x0002): tried: '/Users/amelvin/.platformio/packages/contrib-pioremote/_cffi_backend.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/amelvin/.platformio/packages/contrib-pioremote/_cffi_backend.cpython-311-darwin.so' (no such file), '/Users/amelvin/.platformio/packages/contrib-pioremote/_cffi_backend.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `python -m pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq/index.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================

I cannot solve this… I’ve tried as many things as I can… installed python using brew… tried installing cffi but this doesn’t work.

My background is C++ I have zero experience with python or how all these complex things are interacting. It was all working fine and then on reinstall has totally broken…

Any help would be appreciated…

amelvin@MacBook-Air ➜ ProtoType Debug Board python -m pip install -U platformio

Requirement already satisfied: platformio in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (6.1.16b1)

Requirement already satisfied: bottle==0.12.* in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (0.12.25)

Requirement already satisfied: click<9,>=8.0.4 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (8.1.7)

Requirement already satisfied: colorama in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (0.4.6)

Requirement already satisfied: marshmallow==3.* in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (3.22.0)

Requirement already satisfied: pyelftools<1,>=0.27 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (0.31)

Requirement already satisfied: pyserial==3.5.* in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (3.5)

Requirement already satisfied: requests==2.* in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (2.32.3)

Requirement already satisfied: semantic-version==2.10.* in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (2.10.0)

Requirement already satisfied: tabulate==0.* in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (0.9.0)

Requirement already satisfied: ajsonrpc==1.2.* in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (1.2.0)

Requirement already satisfied: starlette<0.39,>=0.19 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (0.38.2)

Requirement already satisfied: uvicorn<0.31,>=0.16 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (0.30.6)

Requirement already satisfied: wsproto==1.* in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (1.2.0)

Requirement already satisfied: chardet<6,>=3.0.2 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from platformio) (5.2.0)

Requirement already satisfied: packaging>=17.0 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from marshmallow==3.*->platformio) (24.1)

Requirement already satisfied: charset-normalizer<4,>=2 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from requests==2.*->platformio) (3.3.2)

Requirement already satisfied: idna<4,>=2.5 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from requests==2.*->platformio) (3.7)

Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from requests==2.*->platformio) (2.2.2)

Requirement already satisfied: certifi>=2017.4.17 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from requests==2.*->platformio) (2024.7.4)

Requirement already satisfied: h11<1,>=0.9.0 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from wsproto==1.*->platformio) (0.14.0)

Requirement already satisfied: anyio<5,>=3.4.0 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from starlette<0.39,>=0.19->platformio) (4.4.0)

Requirement already satisfied: sniffio>=1.1 in /Users/amelvin/.platformio/penv/lib/python3.11/site-packages (from anyio<5,>=3.4.0->starlette<0.39,>=0.19->platformio) (1.3.1)

I have managed to solve it. The issue is that uninstalling PIO does not remove the downloaded dependent files, which includes this broken cryptography.

I located these in
/Users/amelvin/.platformio/packages

I then deleted the contrib-pioremote folder which prompted it to be reinstalled and then work. removing and reinstalling PIO does not remove these packages