1

'''Error in py_initialize(config$python, config$libpython, config$pythonhome, :
/Users/abhiishekchugh/miniconda3/envs/r-reticulate/lib/libpython3.7m.dylib

  • dlopen(/Users/abhiishekchugh/miniconda3/envs/r-reticulate/lib/libpython3.7m.dylib, 0x000A): tried: '/Users/abhiishekchugh/miniconda3/envs/r-reticulate/lib/libpython3.7m.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libpython3.7m.dylib' (no such file)'''

This is the error I get everytime I use keras on M1 Mac as Miniconda3 doesn't have arm support apparently... Is there any work around for this? I am using this in the latest R version 4.1.1 (2021-08-10) Please help me.

user438383
  • 5,716
  • 8
  • 28
  • 43

1 Answers1

0

The current release of Tensorflow (2.7) does not support M1 Macs. However, there is a lot of on going work in this space. For the time being, until official support is available, Apple is providing a custom build of Tensorflow specifically for M1 Macs. You can install it by following the directions here: https://developer.apple.com/metal/tensorflow-plugin/

Once that is installed, you can point R at the custom installation by setting the environment variable RETICULATE_PYTHON=/path/to/python/bin/python. For reference, you can also refer to the "Apple Silicon" section in https://www.rdocumentation.org/packages/tensorflow/versions/2.6.0/topics/install_tensorflow, or by typing ?tensorflow::install_tensorflow at the R console.

t-kalinowski
  • 1,420
  • 11
  • 21
  • I followed these exact instructions, but unfortunately I still get the same error. – Pame May 26 '22 at 06:08
  • Are you also running the arm64 build of R? This error can also occur if you have an x86 build of R running under rosetta. – t-kalinowski May 26 '22 at 12:35