系统环境:Win10 64位操作系统,已装有vs2013.
安装包:
python-3.7.6【python-3.7.6-amd64.exe】
下载地址:https://www.python.org/downloads/windows/
tensorflow-2.1.0【tensorflow-2.1.0-cp37-cp37m-win_amd64.whl】
下载地址(清华大学开源软件镜像站):https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/tensorflow/
安装步骤如下:
# python安装目录(注:安装时未设置修改环境变量)
D:\Programs\Python\Python37
# 查看python版本
C:\WINDOWS\system32>d:
D:\>cd D:\Programs\Python\Python37
D:\Programs\Python\Python37>python --version
Python 3.7.6
# 查看pip版本
D:\Programs\Python\Python37>cd Scripts
D:\Programs\Python\Python37\Scripts>pip --version
pip 19.2.3 from d:\programs\python\python37\lib\site-packages\pip (python 3.7)
# 创建虚拟环境
D:\Programs\Python\Python37>python -m venv D:\dev_py\py-3.7.6\tf_env
# 激活虚拟环境
cd D:\dev_py\py-3.7.6\tf_env\Scripts
activate
(tf_env) D:\dev_py\py-3.7.6\tf_env\Scripts>
# 更新pip
(tf_env) D:\dev_py\py-3.7.6\tf_env\Scripts>python -m pip install --upgrade pip
Successfully uninstalled pip-19.2.3
Successfully installed pip-20.0.2
注:
1)安装tensorflow前,不要先安装Anaconda;
2)如果安装中报错,如“Read timed out.”,下载报错的依赖包后,手动安装依赖包,然后重新安装tensorflow.
# 离线安装tensorflow[2.1.0]
(tf_env) D:\dev_py\py-3.7.6\tf_env\Scripts>pip in