apple / tensorflow_macos

TensorFlow for macOS 11.0+ accelerated using Apple's ML Compute framework.
Other
3.67k stars 310 forks source link

ImportError: dlopen( ... _pywrap_tensorflow_internal.so: mach-o, but wrong architecture #273

Open dcsan opened 3 years ago

dcsan commented 3 years ago

after installing and trying a basic TF project I get the error below:

ImportError: dlopen( ... _pywrap_tensorflow_internal.so: mach-o, but wrong architecture

python main.py
Traceback (most recent call last):
  File "/Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: dlopen(/Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found.  Did find:
    /Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture
    /Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    from nlp.compare import Compare
  File "/Users/dc/dev/nlp/tony/server/nlp/compare.py", line 3, in <module>
    import tensorflow as tf
  File "/Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 39, in <module>
    from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
  File "/Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: dlopen(/Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found.  Did find:
    /Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture
    /Users/dc/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
AliAghamirbabaei commented 3 years ago

Same here

`import tensorflow as tf Traceback (most recent call last): File "/Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: dlopen(/Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found. Did find: /Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture /Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/init.py", line 41, in from tensorflow.python.tools import module_util as _module_util File "/Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/init.py", line 39, in from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow File "/Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 83, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "/Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: dlopen(/Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found. Did find: /Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture /Users/aliaghamirbabaei/Documents/WorkSpace/Python/ML-Trader/env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.`

devnev39 commented 3 years ago

Uninstall the previous version and install according to instruction: https://www.ai-buzz.com/18-steps-to-install-tensorflow_macos-on-m1-macbook-2020/ Follow this steps