MacOS 安装 TensorFlow2.1.0

环境:

Mac  10.15.3 (19D76)

Python 3.6.8:https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.9.pkg

TensorFlow: 2.1.0

 

1.下载安装Python安装包,打开pkg并安装。

wget -i -c https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.9.pkg

 

2.进入安装目录。设置软件源、升级pip

cd /Library/Frameworks/Python.framework/Versions/3.6/bin
./pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
./pip3 install pip -U

 

3.升级setuptools工具,因为安装tensorflow一些包需要最新版本

./pip3 install --upgrade setuptools

 

4. 查询可以安装的TensorFlow版本

cd /Library/Frameworks/Python.framework/Versions/3.6/bin
./pip3 search tensorflow
➜  / pip3 search tensorflow
tensorflow (2.1.0)                                - TensorFlow is an open source machine learning framework for everyone.
tensorflow-qndex (0.0.22)                         - tensorflow-qnd x tensorflow-extenteten
tensorflow-plot (0.3.2)                           - TensorFlow Plot

 

5.指定安装tensorflow2.1.0

./pip3 install tensorflow==2.1.0

期间可能会有版本依赖或版本太低,导致无法安装,根据提示安装依赖库即可。如 ./pip3 install h5py 

 

6.验证安装是否成功

➜  bin ./python3
Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42
>>>

 

上一篇:face_recognition人脸识别在ubuntu或raspberry安装使用


下一篇:python3.8与pip3安装