在anaconda中配置tensorflow和opencv并运行hello world
下载地址:
官网:https://www.anaconda.com/
最新版本下载地址:https://www.anaconda.com/download/
历史版本:https://repo.anaconda.com/archive/
注意安装不同的版本,不同的python版本对应不同的anaconda版本,笔者python3.6,安装版本为anaconda3-5.0.1
软件安装:
启动:
创建虚拟环境,对应的python3.6版本,输入名字为tensorflow:
选择不同的tensorflow版本,点击右下角的应用。
选择opencv版本,点击应用:
再到home下安装jupyter:
然后再回到工作环境下,并点击小三角,在jupyter中打开:
代开显示:可以打开自己的桌面文件等,此时环境已经配置好了。
程序编写:
代码:注意,因为我的TensorFlow为2.1.0,版本,所以导入TensorFlow时如下。
import cv2
import tensorflow.compat.v1 as tf
tf.compat.v1.disable_eager_execution()
hellow = tf.constant("hellow world!")
sess = tf.compat.v1.Session()
print(sess.run(hellow))
保存并点击运行: