I am building an app with a vue.js front end with a FastAPI back end. I was having some backend issues with Python 3.11 (uvicorn getting Internal Server Errors) so have just rolled back to 3.10 following some advice I got. However, I'm now getting crypto errors on start.
The errors I'm getting are as follows:
OSError: Cannot load native module 'Crypto.Hash._SHA256': Not found '_SHA256.cpython-310-darwin.so',
Cannot load '_SHA256.abi3.so': cannot load library '.../backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so': dlopen(.../backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so, 0x0002): tried: '.../backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
'.../backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (no such file), '.../backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),
'.../backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '.../backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (no such file),
'.../backend/venv/lib/python3.10/site-packages/Crypto/Hash/_SHA256.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')). Additionally, ctypes.util.find_library() did not manage to locate a library called '.../backend/venv/lib/python3.10/site-packages/Crypto/Util/../Hash/_SHA256.abi3.so', Not found '_SHA256.so'
ERROR: "start:backend" exited with 1.
This looks like an issue with venv and pycryptodome, so I've tried uninstalling it and reinstalling it from fresh, but I'm still getting the same problem. It also looks like it's an issue because I'm running this on an M1 Mac.
Has anyone come across this error before and know a good fix? I've been doing a lot of searching and just found a few GitHub issues raised on other projects, with no fixes really presented.