python3、pip 、tensorflow安装(OS系统、终端操作)

    新本子一片空白,需要用tensorflow跑结果。本子自带python2点版本,现在需要安装python3、pip、tensorflow,安装方法查了很多种,用的homedrew安装的,不得不说,很省事,很方便。

   1、查看版本:python -V   (V大写),显示的是安装的版本类型。(要用python3的话,就是python3 -V)

   2、安装homedrew,这个真心方便,https://brew.sh这个界面点进去,复制:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
到终端,然后计算机自动下载完成。


3、安装python3:输入命令:brew install python3 (此部操作同时下载pip。)

4、安装tensorflow: pip3 install tensorflow  。

5、顺利的话,没有问题了就。

测试安装:1、进入python3,输入:python3 

                2、import tensorflow as tf

                

  1. node1 = tf.constant(3.0, dtype=tf.float32)  
  2. node2 = tf.constant(4.0)# also tf.float32 implicitly  
  3. print(node1, node2)
  1. Tensor("Const:0", shape=(), dtype=float32) Tensor("Const_1:0",shape=(), dtype=float32)  
  1. sess = tf.Session()  
  2. print(sess.run([node1, node2]))

  1. node3 = tf.add(node1, node2)  
  2. print("node3:", node3)  
  3. print("sess.run(node3):", sess.run(node3))  

结果出来是:

  1. node3:Tensor("Add:0", shape=(), dtype=float32)  
  2. sess.run(node3):7.0  

说明安装成功!

参考文献:https://blog.csdn.net/lengguoxing/article/details/78456279

               https://www.cnblogs.com/i-am-lvjiazhen/p/6264354.html

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值