- 创建虚拟环境命名tensorflow,(注意python版本,下载包的版本要低于python版本)
conda create -n tensorflow python=3.7.0
2.激活虚拟环境
activate tensorflow
3.查看python路径
where python
4.安装ipython
pip install ipython
5.安装tensorflow
pip install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
6.测试(依次输入)
python
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant("Hello!TensorFlow")
sess=tf.compat.v1.Session()
print(sess.run(hello))
注意:可能会报错:TypeError: Descriptors cannot not be created directly
遵循第一条提示,降低protobuf版本就可以了
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple protobuf==3.19.0