PIO remote error Raspberry pi 4

Hi,
I was running my pio remote for some time and all was well. Now after running command “pio remote agent run” the installation of platformio/contrib-pysite @ ~2.37.0 starts and Tool Manager: contrib-pysite @ 2.37.191020 has been installed!
and suddenly all goes wrong:

My raspian version VERSION=“10 (buster)”
My PIO version is 5.0.1 and I use only the core CLI installation.

I did a uninstall “pip uninstall platformio” and reinstall python3 -c “$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)”

And no change.

There is lots of steps going on but here is the part where it happens:

 Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /home/pi/.platformio/penv/bin/python /home/pi/.platformio/penv/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-hhys1cme/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"''
       cwd: None
  Complete output (84 lines):
  Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple
  Collecting setuptools>=40.6.0
    Using cached setuptools-50.3.0.zip (2.2 MB)
  Collecting wheel
    Using cached wheel-0.35.1.tar.gz (59 kB)
  Collecting cffi!=1.11.3,>=1.8
    Using cached cffi-1.14.2.tar.gz (470 kB)
  Collecting pycparser
    Using cached pycparser-2.20.tar.gz (161 kB)
  Skipping wheel build for setuptools, due to binaries being disabled for it.
  Skipping wheel build for wheel, due to binaries being disabled for it.
  Skipping wheel build for cffi, due to binaries being disabled for it.
  Skipping wheel build for pycparser, due to binaries being disabled for it.
  Installing collected packages: setuptools, wheel, pycparser, cffi
      Running setup.py install for setuptools: started
      Running setup.py install for setuptools: finished with status 'done'
      Running setup.py install for wheel: started
      Running setup.py install for wheel: finished with status 'done'
      Running setup.py install for pycparser: started
      Running setup.py install for pycparser: finished with status 'done'
      Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /home/pi/.platformio/penv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_pwyfamh/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_pwyfamh/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d547iuo1/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-hhys1cme/overlay --compile --install-headers /tmp/pip-build-env-hhys1cme/overlay/include/site/python3.7/cffi
           cwd: /tmp/pip-install-_pwyfamh/cffi/
      Complete output (56 lines):
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libffi' found
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-armv7l-3.7
      creating build/lib.linux-armv7l-3.7/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/lock.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/api.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/cparser.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/recompiler.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/verifier.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/error.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/commontypes.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/model.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/__init__.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/_embedding.h -> build/lib.linux-armv7l-3.7/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-3.7/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-armv7l-3.7
      creating build/temp.linux-armv7l-3.7/c
      arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/home/pi/.platformio/penv/include -I/usr/include/python3.7m -c c/_cffi_backend.c -o build/temp.linux-armv7l-3.7/c/_cffi_backend.o
      c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
       #include <ffi.h>
                ^~~~~~~
      compilation terminated.
      error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /home/pi/.platformio/penv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_pwyfamh/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_pwyfamh/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d547iuo1/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-hhys1cme/overlay --compile --install-headers /tmp/pip-build-env-hhys1cme/overlay/include/site/python3.7/cffi Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /home/pi/.platformio/penv/bin/python /home/pi/.platformio/penv/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-hhys1cme/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.
Error: Traceback (most recent call last):
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/package/manager/core.py", line 88, in inject_contrib_pysite
    from OpenSSL import SSL
  File "/home/pi/.platformio/packages/contrib-pysite/OpenSSL/__init__.py", line 8, in <module>
  File "/home/pi/.platformio/packages/contrib-pysite/OpenSSL/crypto.py", line 12, in <module>
  File "/home/pi/.platformio/packages/contrib-pysite/cryptography/x509/__init__.py", line 8, in <module>
  File "/home/pi/.platformio/packages/contrib-pysite/cryptography/x509/base.py", line 18, in <module>
  File "/home/pi/.platformio/packages/contrib-pysite/cryptography/x509/extensions.py", line 20, in <module>
  File "/home/pi/.platformio/packages/contrib-pysite/cryptography/hazmat/primitives/constant_time.py", line 11, in <module>
ImportError: /home/pi/.platformio/packages/contrib-pysite/cryptography/hazmat/bindings/_constant_time.abi3.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/__main__.py", line 109, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/commands/__init__.py", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 1256, in invoke
    Command.invoke(self, ctx)
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/commands/remote/command.py", line 48, in cli
    inject_contrib_pysite(verify_openssl=True)
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/package/manager/core.py", line 90, in inject_contrib_pysite
    build_contrib_pysite_deps(get_core_package_dir("contrib-pysite"))
  File "/home/pi/.platformio/penv/lib/python3.7/site-packages/platformio/package/manager/core.py", line 115, in build_contrib_pysite_deps
    dep,
  File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/pi/.platformio/penv/bin/python', '-m', 'pip', 'install', '--no-compile', '--no-binary', ':all:', '-t', '/home/pi/.platformio/packages/contrib-pysite', 'autobahn == 20.4.3']' returned non-zero exit status 1.

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

An unexpected error occurred. Further steps:

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

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

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

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

So you have you tried "No package 'libffi' found" error during pip install · Issue #14 · Kozea/cairocffi · GitHub?

1 Like

Same problem here just trying to use Remote Upload from vscode gui with Raspberry Pi 3B, apt install libffi-dev solved it, but this should be part of the platform io setup, not a manual troubleshooting step.