On conda-installed Python on M1 Macs, snowflake-connector-python crashes with MemoryError: Cannot allocate write+execute memory for ffi.callback(). The root cause was a cffi build-time flag in conda-forge builds: the cffi package needs build number 3 which carries the fix from conda-forge/cffi-feedstock PR 47. Install the fixed cffi in your environment: conda install 'cffi >= 1.15.1=*_3' from conda-forge, then reinstall or import the connector normally.
Fix Snowflake connector MemoryError for ffi.callback() on Apple Silicon
- cffilibrary
- snowflake-connector-pythonlibrary
- snowflake.connectorlibrary
- condatool
- conda-forgeorganization
- conda-forge/cffi-feedstock PR 47product
- +2 more
If import snowflake.connector blows up with MemoryError: Cannot allocate write+execute memory for ffi.callback() on an M1 Mac under conda, your cffi build is the culprit. Run conda install "cffi >= 1.15.1=*_3" (build 3 from conda-forge carries the upstream fix) and restart. Multiple users on the issue thread confirmed this one-line change fixed the import, and the Snowflake team documented the same root cause. No code changes needed on your side. Source: https://github.com/snowflakedb/snowflake-connector-python/issues/1205
Source: https://github.com/snowflakedb/snowflake-connector-python/issues/1205