I'm trying to get stockfish for python working but I am running into issues. This is my code so far.

from stockfish import Stockfish
stockfish = Stockfish('/Users/Me/opt/anaconda3/lib/python3.9/site-packages/stockfish/models.py')

This returns a OSError: [Errno 8] Exec format error: '/Users/Me/opt/anaconda3/lib/python3.9/site-packages/stockfish/models.py'

This is where I downloaded the package from: https://pypi.org/project/stockfish/. After this, as I have a Mac, I downloaded it through homebrew and my installation has a path /opt/homebrew/Cellar/stockfish/15, but this also does not work.

2 Answers 2


Download an appropriate stockfish binary at https://stockfishchess.org/download/.

Remember where it is and use that location and engine filename.

stockfish = Stockfish('/engine_path/engine_filename')
  • 2
    I realized my mistake. The file was inside /opt/homebrew/Cellar/stockfish/15 but I had to do ⌘+Shift+G in order to actually find the stockfish file inside. The final path ended up being /opt/homebrew/Cellar/stockfish/15/bin/stockfish
    – Ozzy08
    Jun 22, 2022 at 18:53
  • Thanks I was doing the exact same thing @Ozzy08. This helped alot
    – maxwell
    Oct 3, 2022 at 21:51

I think the path that you give to the Stockfish constructor is wrong.

According to this page https://pypi.org/project/stockfish/ you should rather give the path to where you installed your engine, so probably /opt/homebrew/Cellar/stockfish/15 , not some python file in the stockfish package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.