alexgolec / tda-api

A TD Ameritrade API client for Python. Includes historical data for equities and ETFs, options chains, streaming order book data, complex order construction, and more.
https://tda-api.readthedocs.io
MIT License
1.26k stars 335 forks source link

libffi7 doesn't get installed from the installer for armhf/raspberrypi #316

Closed tifoji closed 2 years ago

tifoji commented 2 years ago

Please read the bug submission guidelines before submitting a bug.

Not following guidelines may result in your bug being ignored and/or closed.

Description of Bug ImportError: libffi.so.7: cannot open shared object file: No such file or directory

Code to Reproduce import tda (or any of the python scripts from the project)

Expected Behavior should import the library and make modules available

Actual Behavior

pi@raspberrypi:~ $ python
Python 3.9.12 (main, Jun 18 2022, 05:42:51) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tda
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.9/site-packages/tda/__init__.py", line 1, in <module>
    from . import auth
  File "/home/pi/.local/lib/python3.9/site-packages/tda/auth.py", line 4, in <module>
    from authlib.integrations.httpx_client import AsyncOAuth2Client, OAuth2Client
  File "/home/pi/.local/lib/python3.9/site-packages/authlib/integrations/httpx_client/__init__.py", line 9, in <module>
    from .oauth1_client import OAuth1Auth, AsyncOAuth1Client, OAuth1Client
  File "/home/pi/.local/lib/python3.9/site-packages/authlib/integrations/httpx_client/oauth1_client.py", line 11, in <module>
    from ..base_client import OAuthError
  File "/home/pi/.local/lib/python3.9/site-packages/authlib/integrations/base_client/__init__.py", line 3, in <module>
    from .sync_openid import OpenIDMixin
  File "/home/pi/.local/lib/python3.9/site-packages/authlib/integrations/base_client/sync_openid.py", line 1, in <module>
    from authlib.jose import jwt, JsonWebToken, JsonWebKey
  File "/home/pi/.local/lib/python3.9/site-packages/authlib/jose/__init__.py", line 15, in <module>
    from .rfc7518 import (
  File "/home/pi/.local/lib/python3.9/site-packages/authlib/jose/rfc7518/__init__.py", line 5, in <module>
    from .jwe_algs import JWE_ALG_ALGORITHMS, AESAlgorithm, ECDHESAlgorithm, u32be_len_input
  File "/home/pi/.local/lib/python3.9/site-packages/authlib/jose/rfc7518/jwe_algs.py", line 13, in <module>
    from cryptography.hazmat.primitives.kdf.concatkdf import ConcatKDFHash
  File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py", line 13, in <module>
    from cryptography.hazmat.primitives import constant_time, hashes, hmac
  File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/primitives/hmac.py", line 12, in <module>
    from cryptography.hazmat.backends.openssl.hmac import _HMACContext
  File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/backends/openssl/__init__.py", line 6, in <module>
    from cryptography.hazmat.backends.openssl.backend import backend
  File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 63, in <module>
    from cryptography.hazmat.bindings.openssl import binding
  File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 14, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: libffi.so.7: cannot open shared object file: No such file or directory
tifoji commented 2 years ago

Resolution

Basically libffi7 requires updating apt sources and installing it.

1) Update sources

pi@raspberrypi:/etc/apt/sources.list.d $ cat libffi.list
deb http://ftp.de.debian.org/debian bullseye main 

2) Update the source keys

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 605C66F00D6C9793
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138

3) Update apt with the new source

sudo apt update

4) Install libffi7

sudo apt install libffi7

tifoji commented 2 years ago

You can (should) also comment out or disable the bullseye sources once installed otherwise it will prompt to install the very new release for many other packages.

alexgolec commented 2 years ago

Closing because this is a python installation issue and not a TDA library issue.

I will however leave it up for posterity and future searchers.