Python SDK install issue

I was trying to install Python SDK on Raspberry Pi OS (64bit) and I’m getting the following errors:

$ pip3 install py-algorand-sdk
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting py-algorand-sdk
  Using cached https://files.pythonhosted.org/packages/1f/60/f441c4f7b2a0df0d451661fb10283a2edd0d12e03e8f0eea2314f8261dae/py_algorand_sdk-1.4.0-py3-none-any.whl
Requirement already satisfied: msgpack in ./.local/lib/python3.7/site-packages (from py-algorand-sdk) (1.0.0)
Collecting pycryptodomex>=3.6.0 (from py-algorand-sdk)
  Using cached https://files.pythonhosted.org/packages/f5/79/9d9206688385d1e7a5ff925e7aab1d685636256e34a409037aa7adbbe611/pycryptodomex-3.9.8.tar.gz
Collecting pynacl (from py-algorand-sdk)
  Using cached https://files.pythonhosted.org/packages/cf/5a/25aeb636baeceab15c8e57e66b8aa930c011ec1c035f284170cacb05025e/PyNaCl-1.4.0.tar.gz
  Installing build dependencies ... error
  Complete output from command /usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-92rxb5gn --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools>=40.8.0 wheel "cffi>=1.4.1; python_implementation != 'PyPy'":
  Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple
  Collecting setuptools>=40.8.0
    Using cached https://files.pythonhosted.org/packages/c3/a9/5dc32465951cf4812e9e93b4ad2d314893c2fa6d5f66ce5c057af6e76d85/setuptools-49.6.0-py3-none-any.whl
  Collecting wheel
    Using cached https://files.pythonhosted.org/packages/a7/00/3df031b3ecd5444d572141321537080b40c1c25e1caa3d86cdd12e5e919c/wheel-0.35.1-py2.py3-none-any.whl
  Collecting cffi>=1.4.1
    Using cached https://files.pythonhosted.org/packages/f7/09/88bbe20b76ca76be052c366fe77aa5e3cd6e5f932766e5597fecdd95b2a8/cffi-1.14.2.tar.gz
  Collecting pycparser (from cffi>=1.4.1)
    Using cached https://files.pythonhosted.org/packages/ae/e7/d9c3a176ca4b02024debf82342dab36efadfc5776f9c8db077e8f6e71821/pycparser-2.20-py2.py3-none-any.whl
  Building wheels for collected packages: cffi
    Running setup.py bdist_wheel for cffi: started
    Running setup.py bdist_wheel for cffi: finished with status 'error'
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ozn6v6ee/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-1x5snj0j --python-tag cp37:
    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 bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.linux-aarch64-3.7
    creating build/lib.linux-aarch64-3.7/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/commontypes.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/pkgconfig.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/error.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/recompiler.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/cparser.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/model.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/api.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/lock.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/verifier.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/__init__.py -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/_embedding.h -> build/lib.linux-aarch64-3.7/cffi
    copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-3.7/cffi
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-aarch64-3.7
    creating build/temp.linux-aarch64-3.7/c
    aarch64-linux-gnu-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/usr/include/python3.7m -c c/_cffi_backend.c -o build/temp.linux-aarch64-3.7/c/_cffi_backend.o
    c/_cffi_backend.c:15:10: fatal error: ffi.h: File o directory non esistente
     #include <ffi.h>
              ^~~~~~~
    compilation terminated.
    error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
  
    ----------------------------------------
    Failed building wheel for cffi
    Running setup.py clean for cffi
  Failed to build cffi
  Installing collected packages: setuptools, wheel, pycparser, cffi
    Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ozn6v6ee/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-oeiuvs6a/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-92rxb5gn --compile:
      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-aarch64-3.7
      creating build/lib.linux-aarch64-3.7/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/commontypes.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/error.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/recompiler.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/cparser.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/model.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/api.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/lock.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/verifier.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/__init__.py -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/_embedding.h -> build/lib.linux-aarch64-3.7/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-3.7/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-aarch64-3.7
      creating build/temp.linux-aarch64-3.7/c
      aarch64-linux-gnu-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/usr/include/python3.7m -c c/_cffi_backend.c -o build/temp.linux-aarch64-3.7/c/_cffi_backend.o
      c/_cffi_backend.c:15:10: fatal error: ffi.h: File o directory non esistente
       #include <ffi.h>
                ^~~~~~~
      compilation terminated.
      error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
  
      ----------------------------------------
  Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ozn6v6ee/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-oeiuvs6a/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-92rxb5gn --compile" failed with error code 1 in /tmp/pip-install-ozn6v6ee/cffi/
  
  ----------------------------------------
Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-92rxb5gn --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools>=40.8.0 wheel "cffi>=1.4.1; python_implementation != 'PyPy'"" failed with error code 1 in None

Any idea about what is causing these errors?

Looks like it’s failing to build cffi, which depends on libffi, so try to install the libffi-dev package. Install it using:

sudo apt install libffi-dev

1 Like