2017-10-16 127 views
-1

对于Tensorflow virtualenv(建议),我遵循https://www.tensorflow.org/install/install_mac 的安装说明。ModuleNotFoundError:在Mac OS上安装后没有名为'tensorflow'的模块

pip3 install --upgrade virtualenv 
virtualenv --system-site-packages -p python3 

安装无痛,没有错误信息。

我激活tensorflow并移动到不同的目录,以避免在导入张量流到Python时与tensorflow目录名称混淆。结果是:

source ~/tensorflow/bin/activate 
(tensorflow) Pers-MacBook-Pro:Documents per$ python3 
Python 3.6.3 (default, Oct 4 2017, 06:09:15) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import tensorflow as tf 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ModuleNotFoundError: No module named 'tensorflow' 

出了什么问题?我在MacOS Sierra上。我跑了诊断脚本tf_env_collect.sh提供有关环境的一些详细信息:

== check pips =================================================== 
numpy (1.13.3) 
protobuf (3.4.0) 
tensorflow (1.3.0) 
tensorflow-tensorboard (0.1.8) 

== check for virtualenv ========================================= 
True 

== tensorflow import ============================================ 
tf.VERSION = 1.3.0 
tf.GIT_VERSION = v1.3.0-rc2-20-g0787eee 
tf.COMPILER_VERSION = v1.3.0-rc2-20-g0787eee 
Sanity check: array([1], dtype=int32) 

== env ========================================================== 
LD_LIBRARY_PATH is unset 
DYLD_LIBRARY_PATH is unset 

== nvidia-smi =================================================== 
./tf_env_collect.sh: line 105: nvidia-smi: command not found 

== cuda libs =================================================== 
+0

您还没有表现出你如何安装它还是你的环境是如何设置的东西。例如,您可能使用了pip而不是pip3等。 – pvg

+0

添加了安装信息。 –

回答

1

我找到了原因:TensorFlow需要Python包,并列入苹果的默认Python安装的版本太旧。

解决方案:升级的Python安装有六个当前版本:

$ sudo easy_install -U six 
相关问题