tensorflow windows安装 Error import tensorflow错误解决方法
2017-01-05 15:39
549 查看
学习资料:
官方关于 Tensorflow 安装的 说明
安装 Tensorflow 时需要注意的几点:
MacOS, Linux, Windows 系统均已支持 Tensorflow
确定你的 python 版本
你的 GPU 是 NVIDIA, 就可以安装 GPU 版本的 Tensorflow; 你的 GPU 不是 NVIDIA 也没有关系, 安装 CPU 版本的就好了.
Tensorflow 的安装方式很多. 比如官网提供的:
Pip 安装
Virtualenv 安装
Anaconda 安装
Docker 安装
从安装源 安装
这节内容使用 pip 在每个系统的安装方式:
Linux 和 MacOS
CPU 版
GPU 版
Windows
测试
更新 Tensorflow
本文将提到第一种最简单的安装方式, pip 安装. 使用 pip 安装的时候要确保你的 pip 已经存在于你的电脑中. 如果还没有安装 pip. 你可以在 Terminal 窗口中运行这个:
CPU 版
激动人心的时刻到了, Tensorflow (0.12) 刚刚做了更新, 绕过了复杂的安装步骤, 如果你只需要安装 CPU 版本的 Tensorflow, 运行下面这个就好了:
注意: 你需要8.1或更高版的
GPU 版
但是 如果你想安装 GPU 版的 Tensorflow, 你要在下面找一个适合你版本的安装文件, 并在 terminal 中执行:
最后, 根据自己的 python 版本, 在 terminal 中执行以下语句:
tf 0.12 版的英文安装说明
安装前的检查:
目前只支持 Python 3.5 (64bit) 版本
你有安装 numpy (没有的话,请看这里numpy 安装教程)
接下来惊心动魄啦! 在 command 窗口中执行
注意 Windows 运行 Tensorflow 如果遇到这个报错:
不要惊慌, 尝试下载安装 Windows 的 Microsoft Visual C++ 2015 redistributable update 3 64 bit. 就能解决这个问题.
然后打开你的 python 编辑器, 输入
运行脚本来检查一下是否有正确安装.
最后, 如果你需要升级 Tensorflow 的版本, 推荐的方式是:
根据你的 python 版本, 在 terminal 中删除原有的版本
然后重复这个安装教程的步骤, 从头安装新版本.
官方关于 Tensorflow 安装的 说明
安装 Tensorflow 时需要注意的几点:
MacOS, Linux, Windows 系统均已支持 Tensorflow
确定你的 python 版本
你的 GPU 是 NVIDIA, 就可以安装 GPU 版本的 Tensorflow; 你的 GPU 不是 NVIDIA 也没有关系, 安装 CPU 版本的就好了.
安装 Tensorflow
Tensorflow 的安装方式很多. 比如官网提供的:Pip 安装
Virtualenv 安装
Anaconda 安装
Docker 安装
从安装源 安装
这节内容使用 pip 在每个系统的安装方式:
Linux 和 MacOS
CPU 版
GPU 版
Windows
测试
更新 Tensorflow
Linux 和 MacOS
本文将提到第一种最简单的安装方式, pip 安装. 使用 pip 安装的时候要确保你的 pip 已经存在于你的电脑中. 如果还没有安装 pip. 你可以在 Terminal 窗口中运行这个:# Ubuntu/Linux 64-位 系统的执行代码: $ sudo apt-get install python-pip python-dev # Mac OS X 系统的执行代码: $ sudo easy_install pip $ sudo easy_install --upgrade six
CPU 版
激动人心的时刻到了, Tensorflow (0.12) 刚刚做了更新, 绕过了复杂的安装步骤, 如果你只需要安装 CPU 版本的 Tensorflow, 运行下面这个就好了:
# python 2+ 的用户: $ pip install tensorflow # python 3+ 的用户: $ pip3 install tensorflow
注意: 你需要8.1或更高版的
pip才能顺利安装.
GPU 版
但是 如果你想安装 GPU 版的 Tensorflow, 你要在下面找一个适合你版本的安装文件, 并在 terminal 中执行:
# Ubuntu/Linux 64-bit, CPU only, Python 2.7 $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0rc0-cp27-none-linux_x86_64.whl # Ubuntu/Linux 64-bit, GPU enabled, Python 2.7 # Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below. $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.0rc0-cp27-none-linux_x86_64.whl # Mac OS X, CPU only, Python 2.7: $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0rc0-py2-none-any.whl # Mac OS X, GPU enabled, Python 2.7: $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.0rc0-py2-none-any.whl # Ubuntu/Linux 64-bit, CPU only, Python 3.4 $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0rc0-cp34-cp34m-linux_x86_64.whl # Ubuntu/Linux 64-bit, GPU enabled, Python 3.4 # Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below. $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.0rc0-cp34-cp34m-linux_x86_64.whl # Ubuntu/Linux 64-bit, CPU only, Python 3.5 $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0rc0-cp35-cp35m-linux_x86_64.whl # Ubuntu/Linux 64-bit, GPU enabled, Python 3.5 # Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below. $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-linux_x86_64.whl # Mac OS X, CPU only, Python 3.4 or 3.5: $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0rc0-py3-none-any.whl # Mac OS X, GPU enabled, Python 3.4 or 3.5: $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.0rc0-py3-none-any.whl
最后, 根据自己的 python 版本, 在 terminal 中执行以下语句:
# 如果你是 Python 2, 请复制下面 $ sudo pip install --upgrade $TF_BINARY_URL # 如果你是 Python 3, 请复制下面 $ sudo pip3 install --upgrade $TF_BINARY_URL
Windows
tf 0.12 版的英文安装说明安装前的检查:
目前只支持 Python 3.5 (64bit) 版本
你有安装 numpy (没有的话,请看这里numpy 安装教程)
接下来惊心动魄啦! 在 command 窗口中执行
# CPU 版的 C:\> pip install tensorflow # GPU 版的 C:\> pip install tensorflow-gpu
注意 Windows 运行 Tensorflow 如果遇到这个报错:
Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory; please exit the tensorflow source tree, and relaunch your python interpreter from there.
不要惊慌, 尝试下载安装 Windows 的 Microsoft Visual C++ 2015 redistributable update 3 64 bit. 就能解决这个问题.
测试
然后打开你的 python 编辑器, 输入import tensorflow
运行脚本来检查一下是否有正确安装.
更新 Tensorflow
最后, 如果你需要升级 Tensorflow 的版本, 推荐的方式是:根据你的 python 版本, 在 terminal 中删除原有的版本
# 如果你是 Python 2, 请复制下面 pip uninstall tensorflow # 如果你是 Python 3, 请复制下面 pip3 uninstall tensorflow
然后重复这个安装教程的步骤, 从头安装新版本.
相关文章推荐
- 关于windows安装python过程中出现error 2503 2502错误的解决方法
- windows 下安装tensorflow报错,pywrap_tensorflow.py in swig_import_helper
- Window10 + tensorflow 安装(解决Error importing tensorflow, unless you are using bazel...)
- 关于windows安装python过程中出现error 2503 2502错误的解决方法
- tensorFlow解决问题ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'
- mysql安装时产生cannot create windows service for mysql.error:0的解决方法
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. 错误解决方法
- Windows 7/Vista 安装软件时出现Error 1935总结及解决方法
- 安装GD库错误解决方法 configure.ac:64: error: possibly undefined macro: AM_ICONV
- Windows 7 安装软件错误:“Error 1935 ...HRESULT: 0x800736FD” 的解决办法
- Windows 7安装ArcGIS DeskTop10:错误1935解决方法
- Windows下安装UCM文件系统的语义错误解决方法
- Windows 7 安装软件错误:“Error 1935 ...HRESULT: 0x800736FD” 的解决办法
- VirtualBox安装error错误代码3解决方法
- Windows7下安装ENVI4.7出现“Error 1935”错误的解决方法
- 修改MBR,解决安装Windows时Error 17错误。
- 关于MySql安装后出现error:0错误,我的解决方法
- android-sdk-windows安装重命名错误解决方法
- 虚拟机安装Windows 8出现0xc0000260错误的解决方法
- 启动 Microsoft Windows Media Player 时,收到“An internal application error has occurred”错误信息的解决方法