Skip to content
Advertisement

ImportError: dlopen(…): Library not loaded: @rpath/_pywrap_tensorflow_internal.so

I am a beginner at machine learning. I try to use LSTM algorism but when I write

from keras.models import Sequential

it shows error as below:

ImportError: dlopen(/Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/_pywrap_tfe.so, 2): Library not loaded: @rpath/_pywrap_tensorflow_internal.so
  Referenced from: /Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/_pywrap_tfe.so
  Reason: image not found

How can I fix this? Thank you so much!

full error message:

Traceback (most recent call last):
  File "/Users/wangzifan/Desktop/machine/LSTM.py", line 39, in <module>
    from keras.models import Sequential
  File "/Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/keras/__init__.py", line 21, in <module>
    from tensorflow.python import tf2
  File "/Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/tensorflow/__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 37, in <module>
    from tensorflow.python.eager import context
  File "/Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/eager/context.py", line 33, in <module>
    from tensorflow.python import pywrap_tfe
  File "/Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/pywrap_tfe.py", line 25, in <module>
    from tensorflow.python._pywrap_tfe import *
ImportError: dlopen(/Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/_pywrap_tfe.so, 2): Library not loaded: @rpath/_pywrap_tensorflow_internal.so
  Referenced from: /Users/wangzifan/opt/anaconda3/lib/python3.9/site-packages/tensorflow/python/_pywrap_tfe.so
  Reason: image not found

Advertisement

Answer

Problem solved. install tensorflow again with

sudo pip3 install tensorflow

and change the import to

from tensorflow.python.keras.models import Sequential
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement