0

I got a new m1 MacBook Pro and installed the TensorFlow 2 provided by Apple, and I decided to do some testing for the MacBook, so I installed the python3 package "AIBenchmark", and the process was successful without any error messages. However, when I imported it, the following error message appeared.

Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
File "/Users/andrew/tensorflow_macos_venv/lib/python3.8/site-packages/ai_benchmark/__init__.py",
line 5, in <module>
    from ai_benchmark.utils import *
File "/Users/andrew/tensorflow_macos_venv/lib/python3.8/site-packages/ai_benchmark/utils.py",
line 10, in <module>
    from PIL import Image
File "/Users/andrew/tensorflow_macos_venv/lib/python3.8/site-packages/PIL/Image.py",
line 94, in <module>
    from . import _imaging as core ImportError: dlopen(/Users/andrew/tensorflow_macos_venv/lib/python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so,
2): no suitable image found.  Did find:
  /Users/andrew/tensorflow_macos_venv/lib/python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so:
mach-o, but wrong architecture
  /Users/andrew/tensorflow_macos_venv/lib/python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so:
mach-o, but wrong architecture 

How do I solve this problem?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

1 Answers1

0

I'm guessing that since AI Benchmark has not been updated since Dec. 18, 2019, the library is an Intel architecture binary. I don't know the details of the python 3.8 installation via the Xcode Command Line Tools, but I imagine it's a universal binary (both Intel and Apple Arm64 architecture). My guess is that you'll have to run TensorFlow as an Intel binary, so I would try the following in the terminal: precede your command to startup your app with

arch -x86_64

Or, configure Terminal to run under Rosetta2.

  1. Right-click on Terminal in Finder
  2. Get Info
  3. Open with Rosetta

More suggestions here (no, it's not python or TensorFlow related, but yes, it's relevant).

pfurbacher
  • 1,789
  • 3
  • 15
  • 23