-1

I have followed the installation instruction on https://www.tensorflow.org/install/install_mac for Tensorflow virtualenv (as recommended).

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

The installation was painless without error messages.

I activate tensorflow and move to a different directory to avoid confusion with tensorflow directory name when importing tensorflow to Python. The result is:

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'

What is wrong? I'm on MacOS Sierra. I ran the diagnostics script tf_env_collect.sh to provide some more info about the environment:

== 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  ===================================================
Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76

1 Answers1

1

I found the reason: TensorFlow requires the Python package six, and the version included in Apple's default Python installation is too old.

Solution: Upgrade the Python installation with the current version of six:

$ sudo easy_install -U six
Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76