mac上默認(rèn)裝有python,先看一下python的版本侵蒙,
python3 以上的版本默認(rèn)有pip ,所以2.7需要手動(dòng)安裝pip,安裝命令
sudo easy_install pip
tensorflow1.2以上版本macos上不支持gpu趟脂,現(xiàn)在tensorflow1.8已經(jīng)發(fā)布了。
安裝cpu版本:
pip install tensorflow
失敗了:
Collecting html5lib==0.9999999 (from tensorboard<1.9.0,>=1.8.0->tensorflow)
Using cached https://files.pythonhosted.org/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: numpy, pbr, funcsigs, six, mock, enum34, wheel, astor, backports.weakref, termcolor, gast, protobuf, futures, grpcio, absl-py, markdown, html5lib, bleach, werkzeug, tensorboard, tensorflow
Found existing installation: numpy 1.8.0rc1
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
sniper:~ chris$ cd /usr/lib/python2.7/
貌似少一些依賴關(guān)系例衍、還有不兼容的問(wèn)題
先執(zhí)行兩命令看看
sudo easy_install nose
sudo easy_install tornado
再解決兼容問(wèn)題:
在終端運(yùn)行:
sudo pip install --ignore-installed numpy
完成后運(yùn)行
pip install tensorflow
執(zhí)行
pip install --user tensorflow
按照錯(cuò)誤提示命令執(zhí)行,但是依然會(huì)報(bào)錯(cuò) ,原因是沒有權(quán)限.
所以執(zhí)行:
sudo pip install --upgrade pip
最后再執(zhí)行
pip install --user tensorflow
驗(yàn)證一下:
import tensorflow as tf
hello=tf.constant("hello tensorflow")
sess=tf.Session()
print(sess.run(hello))
沒毛病