Install tensorflow and run hello world in MacBook pro : MacOS
Install tensorflow and run hello world in MacBook pro / MacOS
install tensorflow
localhost:git xubo$ pip3 install tensorflow Collecting tensorflow Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/70/78/cd74769027b6249e45807637c1aa3ef212b9492349cca4b87e5de1a10548/tensorflow-1.11.0-cp36-cp36m-macosx_10_11_x86_64.whl (59.3MB) 100% |████████████████████████████████| 59.4MB 23kB/s Collecting absl-py>=0.1.6 (from tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/16/db/cce5331638138c178dd1d5fb69f3f55eb3787a12efd9177177ae203e847f/absl-py-0.5.0.tar.gz (90kB) 100% |████████████████████████████████| 92kB 164kB/s Collecting numpy>=1.13.3 (from tensorflow) Downloading https://files.pythonhosted.org/packages/0a/2b/726b7d4e4ba844d4805c52b8e05299a5f49bc16c69ca0fa8e1964c0871fe/numpy-1.15.2-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (24.5MB) 100% |████████████████████████████████| 24.5MB 41kB/s Collecting wheel>=0.26 (from tensorflow) Downloading https://files.pythonhosted.org/packages/fc/e9/05316a1eec70c2bfc1c823a259546475bd7636ba6d27ec80575da523bc34/wheel-0.32.1-py2.py3-none-any.whl Requirement already satisfied: setuptools<=39.1.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tensorflow) Collecting protobuf>=3.6.0 (from tensorflow) Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/c7/27/133f225035b9539f2dcfebcdf9a69ff0152f56e0120160ec5c972ea7deb9/protobuf-3.6.1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 281kB/s Collecting grpcio>=1.8.6 (from tensorflow) Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/24/1a/84396834b04cd43be3c10f5faeadf62d01689b704b3c99d09e1e08a41d9b/grpcio-1.15.0-cp36-cp36m-macosx_10_7_intel.whl (2.0MB) 100% |████████████████████████████████| 2.0MB 164kB/s Collecting keras-applications>=1.0.5 (from tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/3f/c4/2ff40221029f7098d58f8d7fb99b97e8100f3293f9856f0fb5834bef100b/Keras_Applications-1.0.6-py2.py3-none-any.whl (44kB) 100% |████████████████████████████████| 51kB 354kB/s Collecting six>=1.10.0 (from tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl Collecting termcolor>=1.1.0 (from tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz Collecting gast>=0.2.0 (from tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/5c/78/ff794fcae2ce8aa6323e789d1f8b3b7765f601e7702726f430e814822b96/gast-0.2.0.tar.gz Collecting keras-preprocessing>=1.0.3 (from tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/fc/94/74e0fa783d3fc07e41715973435dd051ca89c550881b3454233c39c73e69/Keras_Preprocessing-1.0.5-py2.py3-none-any.whl Collecting astor>=0.6.0 (from tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl Collecting tensorboard<1.12.0,>=1.11.0 (from tensorflow) Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/9b/2f/4d788919b1feef04624d63ed6ea45a49d1d1c834199ec50716edb5d310f4/tensorboard-1.11.0-py3-none-any.whl (3.0MB) 100% |████████████████████████████████| 3.0MB 163kB/s Collecting h5py (from keras-applications>=1.0.5->tensorflow) Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/44/81/50a0560aac57a33c2a624d9e160735f39d7a6324e3f6f115425a1bf01dd9/h5py-2.8.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (6.0MB) 100% |████████████████████████████████| 6.1MB 128kB/s Collecting markdown>=2.6.8 (from tensorboard<1.12.0,>=1.11.0->tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/7a/6b/5600647404ba15545ec37d2f7f58844d690baf2f81f3a60b862e48f29287/Markdown-3.0.1-py2.py3-none-any.whl (89kB) 100% |████████████████████████████████| 92kB 130kB/s Collecting werkzeug>=0.11.10 (from tensorboard<1.12.0,>=1.11.0->tensorflow) Cache entry deserialization failed, entry ignored Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB) 100% |████████████████████████████████| 327kB 337kB/s Installing collected packages: six, absl-py, numpy, wheel, protobuf, grpcio, h5py, keras-applications, termcolor, gast, keras-preprocessing, astor, markdown, werkzeug, tensorboard, tensorflow Running setup.py install for absl-py ... done Running setup.py install for termcolor ... done Running setup.py install for gast ... done Successfully installed absl-py-0.5.0 astor-0.7.1 gast-0.2.0 grpcio-1.15.0 h5py-2.8.0 keras-applications-1.0.6 keras-preprocessing-1.0.5 markdown-3.0.1 numpy-1.15.2 protobuf-3.6.1 six-1.11.0 tensorboard-1.11.0 tensorflow-1.11.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.32.1 localhost:git xubo$ localhost:git xubo$
##Run hello world:
localhost:git xubo$ python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import tensorflow as tf
>>> tf.enable_eager_execution()
>>> tf.add(1, 2)
2018-10-20 23:22:39.697654: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
<tf.Tensor: id=2, shape=(), dtype=int32, numpy=3>
>>> tf.add(12, 23)
<tf.Tensor: id=6, shape=(), dtype=int32, numpy=35>
>>> hello = tf.constant(‘Hello, TensorFlow!’)
>>> hello.numpy()
b’Hello, TensorFlow!’
>>>
Error:
localhost:git xubo$ python Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] 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' >>> quit()
use pip3 instead of pip