我想练习tensorflow 2,但是我在anaconda环境中安装它的尝试失败。
我的问题是:如何安装tensorflow 2?如果可以在anaconda环境中完成,对我来说似乎更方便。只要可以使用tensorflow 2,就不需要理解下面的错误消息。
首先,我发现使用pip
而不是conda
第二,pip
给我带来很多错误:每当我感觉到自己转过身来时,就会出现另一个错误……我认为最好的是(在py36环境中) ):
pip install --upgrade --ignore-installed wrapt tensorflow==2.0.0-beta1
。
的确,在卸载了tb-nightly,notebook和jupyter之后,此命令运行时没有明显的错误/警告。但是,python中的import tensorflow
给了我这个错误:
Traceback (most recent call last):
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/Users/steph/anaconda/envs/py36/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/Users/steph/anaconda/envs/py36/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _SecKeyCopyExternalRepresentation
Referenced from: /Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.2.dylib
Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
in /Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.2.dylib
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/Users/steph/anaconda/envs/py36/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/Users/steph/anaconda/envs/py36/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _SecKeyCopyExternalRepresentation
Referenced from: /Users/steph/anaconda/envs/py36/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.2.dylib
Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
in /Users/steph/anaconda/envs/py36/lib/python3.6/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.```
答案 0 :(得分:1)
可能您在发布here时遇到了同样的问题..您可以尝试解决此MacOS系统升级问题,或者尝试在将用于代码的virtualenv中安装tensorflow
编辑:
要在您的虚拟环境(本例中为anaconda)中安装软件包,您需要激活已经创建的环境(请参考anaconda docs进行使用)并使用
$ conda activate myenv
(myenv) $ pip install tensorflow
答案 1 :(得分:0)
该Beta是预发布版本,尚不稳定,因此您必须使用--pre标志
pip install --pre tensorflow==2.0.0-beta1