Yes. If you have a polyglot book file. See the 'rm_bookmoves.py' here
https://www.chess.com/blog/e4_guy/chess-analysis-on-linux-command-line-addicts-heaven
Also see the excellent Python chess API https://python-chess.readthedocs.io/en/v1.6.1/polyglot.html
what's the most efficient way to identify an opening from a PGN without reinventing the wheel? is there an existing python implementation/API?