Anaconda和TensorFlow安装且在Jupyter上运行

1.Anaconda安装及Jupyter使用步骤

https://www.bilibili.com/video/av42143495
是一个五分钟的视频,简洁明了,亲测成功

2.Windows环境下安装TensorFlow

打开Anaconda Prompt
Anaconda和TensorFlow安装且在Jupyter上运行_第1张图片
因为po安装的是默认Python3.7,在命令行输入如下,建立一个 conda 计算环境,命名为tensorflow

(base) C:\Users\USER>conda create -n tensorflow python=3.7

激活这个环境,使用 conda 安装 tensorflow,输入如下

(base) C:\Users\USER>activate tensorflow

以后都可以通过这个命令进入tensorflow的环境

安装tensorflow

(tensorflow) C:\Users\USER>pip install tensorflow

如果这个失败的话,可以用

(tensorflow) C:\Users\USER>conda install tensorflow

等待…
测试是否安装好,以及查看版本和路径

(tensorflow)C:\Users\USER>python
···
>>>import tensorflow as tf
>>>tf.__version__
>>>tf.__path__

能出结果就是安装好了

3.Jupyter notebook上使用tensorflow

为了让它能在Jupyter上使用

(tensorflow)C:\Users\USER>conda install ipython
···
(tensorflow)C:\Users\USER>conda install jupyter
···

接着会发现Anaconda目录下多出了一个jupyter notebook(tensorflow),进入测试,就可以了

退出tensorflow环境的话用下面命令二选一

(tensorflow) C:\Users\USER>activate base
(tensorflow) C:\Users\USER>deactivate tensorflow

jupyter notebook(tensorflow)和jupyter notebook的包是不共用的,比如在base环境下用pip安装了matplotlib

(base) C:\Users\USER>python -m pip install -U pip setuptools
(base) C:\Users\USER>python -m pip install matplotlib

jupyter notebook可以用,但是jupyter notebook(tensorflow)不能用,需要在tensorflow环境下,用conda安装

(base) C:\Users\USER>activate tensorflow
(tensorflow) C:\Users\USER>conda install matplotlib

效果如下
Anaconda和TensorFlow安装且在Jupyter上运行_第2张图片

参考文献:
https://blog.csdn.net/index20001/article/details/73555182
https://tf.wiki/zh_hans/basic/installation.html

你可能感兴趣的:(anaconda,tensorflow,python,深度学习,机器学习)