win10+python3.6+tensorflow-cpu+keras+Pycharm环境下的tensorflow配置方法

在pytorch成功配置的基础上,也尝试着把tensorflow和keras安装了一下。

Win 10
Anaconda3-5.2.0-Windows-x86_64.exe
python3.6
tensorflow-cpu 1.15
keras 2.16
Pycharm 2020.1 x64.exe

安装Anaconda

清华大学开源软件镜像站清华Anaconda安装包下载地址
链接进去选择自己需要的版本就可以下载了哈。这里我下的是Anaconda3-5.2.0-Windows-x86_64.exe

anaconda python 版本对应关系

通过Anaconda Prompt 打开

更新一下pip

python -m pip install -U pip 

检测anaconda环境是否安装成功

conda --version

检测目前安装了哪些环境变量

conda info --envs

配置虚拟环境

conda create --name tensorflow python=3.6
conda activate tensorflow

检测当前环境中的python的版本

python --version

退出tensorflow的环境:

deactivate

查看一下所有适配的tensorflow版本

conda search --full --name tensorflow

安装tensorflow==1.15.0

pip install tensorflow==1.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/

测试

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

运行结果

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
b'Hello, TensorFlow!'

安装Keras

再次通过Anaconda Prompt 打开

conda search --full --name keras

安装keras版本需要和python版本、tensorflow版本对应,从查看列表里选择合适版本

activate tensorflow
pip install keras==2.1.6 -i https://pypi.tuna.tsinghua.edu.cn/simple/
conda install mingw libpython

添加环境变量:D:\Anaconda3\Library\mingw-w64\bin

测试

python
import keras

运行结果

Using TensorFlow backend.

Pycharm环境下的tensorflow配置方法

Pycharm 2020.1 下载安装
配置方法同Anaconda+Pycharm环境下的PyTorch配置方法

猜你喜欢

转载自blog.csdn.net/weixin_45656790/article/details/108857742