Windows10(64bit)环境下Python3 + Tensorflow安装

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaoyw/article/details/81901955

  TensorFlow 简介[1]
  TensorFlow™ 是一个开放源代码软件库,用于进行高性能数值计算。借助其灵活的架构,用户可以轻松地将计算工作部署到多种平台(CPU、GPU、TPU)和设备(桌面设备、服务器集群、移动设备、边缘设备等)。TensorFlow™ 最初是由 Google Brain 团队(隶属于 Google 的 AI 部门)中的研究人员和工程师开发的,可为机器学习和深度学习提供强力支持,并且其灵活的数值计算核心广泛应用于许多其他科学领域。
  
  检查Python环境,及各种包的安装情况:

D:\Python\Python36>pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
absl-py (0.4.0)
astor (0.7.1)
click (6.7)
cycler (0.10.0)
decorator (4.3.0)
Flask (1.0.2)
gast (0.2.0)
grpcio (1.14.1)
itsdangerous (0.24)
Jinja2 (2.10)
kiwisolver (1.0.1)
Markdown (2.6.11)
MarkupSafe (1.0)
matplotlib (2.2.2)
networkx (2.1)
numpy (1.14.2+mkl)
opencv-python (3.4.2.17)
pandas (0.23.1)
Pillow (5.1.0)
pip (9.0.1)
protobuf (3.6.1)
pymongo (3.7.0)
pyparsing (2.2.0)
python-dateutil (2.7.2)
pytz (2018.4)
PyWavelets (0.5.2)
scikit-image (0.13.1)
scikit-learn (0.19.1)
scipy (1.0.1)
setuptools (28.8.0)
six (1.11.0)
tensorboard (1.10.0)
tensorflow (1.10.0)
termcolor (1.1.0)
Werkzeug (0.14.1)
wheel (0.31.1)
xgboost (0.72)
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

  其中,grpcio、tensorflow、absl、astor、gast、markdown、protobuf、tensorboard、、 termcolor、wheel等是本次操作安装内容,其他的是以前安装过,其中过程详解如下作者实践的链接供参考:
  1.使用Python Matplotlib绘图并输出图像到文件中的实践,涉及到的包有:six、cycler、pyparsing、python-dateutil 、kiwisolver、numpy、pytz、matplotlib
  2.Python科学计算初探——余弦相似度,涉及到的包有:numpy、 scipy
  3.Python sklearn决策树算法实践,涉及到的包有:scikit-learn
  4.使用Python科学计算包搭建CNN算法实践(1),涉及到的包有:scikit_image、decorator、networkx、Pillow、PyWavelets
  5.XGBoost算法应用入门学习实践,涉及到的包有:xgboost
  6.Python基于Flask开发Restful API实践,涉及到的包有:Jinja、 MarkupSafe、 Werkzeug、 click、 flask、 itsdangerous
  7.Python开发中使用Mongo DB入门实践,涉及到的包有:pymongo

  直接安装Tensorflow时,出现报错:

D:\Python\Python36>pip install tensorflow
Collecting tensorflow
......
FileNotFoundError: [WinError 2] 系统找不到指定的文件。: 'd:\\python\\python36\\Lib\\site-packages\\grpc'

  可能原因是:
这里写图片描述

取消保护,并单独安装GRPC,如果不取消保护,仍安装失败!

D:\Python\Python36>pip install grpcio
Collecting grpcio
......
Installing collected packages: grpcio
Successfully installed grpcio-1.14.1
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

  再次执行安装Tensorflow,安装成功:

D:\Python\Python36>pip install tensorflow
Collecting tensorflow
......
Installing collected packages: absl-py, gast, markdown, wheel, protobuf, tensorboard, termcolor, astor, tensorflow
  Running setup.py install for absl-py ... done
  Running setup.py install for gast ... done
  Running setup.py install for termcolor ... done
Successfully installed absl-py-0.4.0 astor-0.7.1 gast-0.2.0 markdown-2.6.11 protobuf-3.6.1 tensorboard-1.10.0 tensorflow-1.10.0 termcolor-1.1.0 wheel-0.31.1
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

  验证Tensorflow安装,在 Python 交互式 shell 中输入以下几行简短的程序代码:

D:\Python\Python36>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello ,TensorFlow')
>>> sess = tf.Session()
2018-08-21 13:51:54.348867: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
>>> print(sess.run(hello))

  如果系统输出以下内容,说明您可以开始编写 TensorFlow 程序了:

b'Hello ,TensorFlow'

  OpenCV简介[2]
  
  OpenCV是一个基于BSD许可(开源)发行的跨平台计算机视觉库,可以运行在Linux、Windows、Android和Mac OS操作系统上。它轻量级而且高效——由一系列 C 函数和少量 C++ 类构成,同时提供了Python、Ruby、MATLAB等语言的接口,实现了图像处理和计算机视觉方面的很多通用算法。

  图像处理,需要Opencv,在此安装,很简单,操作如下:

D:\Python\Python36>pip install opencv-python
Collecting opencv-python
......
Installing collected packages: opencv-python
Successfully installed opencv-python-3.4.2.17
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

  关于Python安装,参考作者实践:
《Python入门学习(一),安装Eclipse开发环境》 CSDN博客 肖永威 2017.12

猜你喜欢

转载自blog.csdn.net/xiaoyw/article/details/81901955