#python #python-3.x #tensorflow
#python #python-3.x #tensorflow
Вопрос:
Я начал использовать TensorFlow, но после попытки установить TensorFlow и keras в python3.8 на Jupyter notebook у меня появилась ошибка ниже. Не могли бы вы мне помочь, я использую 64-разрядный Python 3.8.1.
Я набираю это:
import tensorflow as tf
Вывод:
ImportError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _SecKeyCopyExternalRepresentation
Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.2.dylib
Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.2.dylib
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-6-64156d691fe5> in <module>
----> 1 import tensorflow as tf
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/__init__.py in <module>
37 # go/tf-wildcard-import
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
---> 39 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
40
41 from tensorflow.python.eager import context
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _SecKeyCopyExternalRepresentation
Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.2.dylib
Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.2.dylib
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.**
Комментарии:
1. попробуйте pip3 установить tensorflow
2. Вы используете macOS? Этот поток похож на ваш случай. github.com/tensorflow/tensorflow/issues/43387 Или вы можете попытаться сообщить о новой проблеме здесь: github.com/tensorflow/tensorflow/issues
Ответ №1:
#check current python version
python --version
#Create the virtual environment
conda create -n tf python=PYTHON_VERSION
#Activate the tf environment
conda activate tf
#Install Jupyter notebook on tf Env
conda install jupyter
#Launch jupyter notebook
jupyter notebook
#Install Tensorflow on Jupter notebook
pip install tensorflow
import tensorflow as tf
tf.__version__