引言: tensorflow大名鼎鼎,这里不再赘述其为何物。这里讲描述在安装python包的时候碰到的“no matching distribution found for tensorflow”,其原因以及如何解决。前途永远是光明的,道路则永远是曲折的。
简单的安装tensorflow
这里安装的tensorflow的cpu版本,gpu版本可以自行搜索安装指南,或者参考如下指令:
pip3 install tensorflow #cpu
这里使用的python 3.6.3版本。
pip3 install tensorflow-gpu
这里是gpu的版本。
window的环境
window 7.
问题描述:
pip3 install tensorflow
如此简单的指令,应该不会出错吧,结果得到如下错误信息:
collecting tensorflow
could not find a version that satisfies the requirement tensorflow (from versions: ) no matching distribution found for tensorflow
为什么没有找到tensorflow呢?那我们自行找找看吧?
pip3 search tensorflow
具体的输出信息如下:
…………………..
tensorbase (0.3) - minimalistic tensorflow
framework
tensorbayes (0.3.0) - deep variational inference in
tensorflow
tensorflow-tensorboard (0.4.0rc3) - tensorboard lets you watch
tensors flow
tensorboard_logger (0.0.4) - log tensorboard events without
tensorflow
tensorboardx (0.8) - tensorboardx lets you watch
tensors flow without tensorflow
tensorbuilder (0.3.6) - a light wrapper over tensorflow
that enables you to easily
create complex deep neural
networks using the builder
pattern through a functional
fluent immutable api
tensorflow-utils (0.1.0) - classes and methods to make
using tensorflow easier
tensorflow-transform (0.4.0) - a library for data
preprocessing with tensorflow
tensorflow (1.5.0rc0) - tensorflow helps the tensors
flow
tensorflow_forward_ad (0.3.3) - tensorflow forward-mode
automatic differentiation
tensorflow_hmm (0.4.1) - tensorflow and numpy
implementations of the hmm
viterbi and forward/backward
algorithms
tensorflow_nlp (0.0.1) - deep learning nlp tasks
implemented on tensorflow
tensorflowonspark (1.1.0) - deep learning with tensorflow
on apache spark clusters
tensorflowservingclient (0.5.1.post2) - prebuilt tensorflow serving
client
tensorforce (0.3.4) - reinforcement learning for
tensorflow
tensorfunk (0.0.0) - tensorflow model converter to
create tensorflow-independent
prediction functions.
tensorfuse (0.0.1) - common interface for theano,
cgt, and tensorflow
tensorgraph (3.5.8) - a high level tensorflow library
for building deep learning
models
tensorhive (0.1.1) - lightweight computing resource
management tool for executing
distributed tensorflow programs
tensorlm (0.3) - tensorflow wrapper for deep
neural text generation on
character or word level with
rnns / lstms
tensormol (0.1) - tensorflow+molecules =
tensormol
tensorpack (0.8.0) - neural network toolbox on
tensorflow
tensorpy (1.1.0) - easy image classification with
tensorflow!
tensorrec (0.1) - a tensorflow recommendation
algorithm and framework in
python.
tensorspark (1.0.6) - tensorflow on spark, a scalable
system for high-performance
machine learning
tensorvision (0.1.dev1) - a library to build and train
neural networks in with
tensorflow for computer vision
tfann (1.0.1) - a neural network module
containing implementations of
mlp, and cnn networks in
tensorflow.
tfboys (0.0.1) - tensorflow boys
tfcf (0.0.0) - a tensorflow-based recommender
system.
tfcoreml (0.1.0) - tensorflow to core ml converter
tfdebugger (0.1.1) - tensorflow debugger
tfdeploy (0.4.2) - deploy tensorflow graphs for
fast evaluation and export to
tensorflow-less environments
running numpy.
tfgraph (0.2) - python’s tensorflow graph
library
tfgraphviz (0.0.6) - a visualization tool to show a
graph like tensorflow and
tensorboard
…………………………………………
悲伤的我如此难以自抑,因为我被这个简单的问题折磨的如此深沉。明明可以找到的,怎么却无法安装嗯?我需要自行好好找找明明是谁? :-)
问题分析
二话不说,直接上官网上查查看,虽然官网离我朝远隔万里,需要跋山涉水之后方可达到。翻过拿到看不见的墙之后,重要可以看到官方信息了。
官方路标如下: https://tensorflow.org/install/install_windows
其中所提安装步骤非常简洁,如此简洁的步骤,怎么可能出错? 于是重新梳理了一下,难道是python或者pip3本身的问题吗?
check pip3
pip –version
发现其为最新版本:
pip 9.0.1 from d:program files (x86)pythonlibsite-packages (python 3.6)
那python呢? 官方文档中提到如下:
if one of the following versions of python is not installed on your machine, install it now:
* python 3.5.x 64-bit from python.org
* python 3.6.x 64-bit from python.org
难道我安装的python是假python不成? 估计有可能吧,难道是64bit的问题?
# 检查python的版本
python -v
得到了python的完整信息:
..........................................> d:program files (x86)pythonlib__pycache__sysconfig.cpython-36.pyc matches d:program files (x86)pythonlibsysconfig.py> code object from 'd:\program files (x86)\python\lib\__pycache__\sysconfig.cpython-36.pyc'import 'sysconfig' # <_frozen_importlib_external.sourcefileloader object at 0x006a1230>> d:program files (x86)pythonlib__pycache___bootlocale.cpython-36.pyc matches d:program files (x86)pythonlib_bootlocale.py> code object from 'd:\program files (x86)\python\lib\__pycache__\_bootlocale.cpython-36.pyc'import '_locale' # <class '_frozen_importlib.builtinimporter'>import '_bootlocale' # <_frozen_importlib_external.sourcefileloader object at 0x007911d0>> d:program files (x86)pythonlibencodings__pycache__gbk.cpython-36.pyc matches d:program files (x86)pythonlibencodingsgbk.py> code object from 'd:\program files (x86)\python\lib\encodings\__pycache__\gbk.cpython-36.pyc'import '_codecs_cn' # <class '_frozen_importlib.builtinimporter'>import '_multibytecodec' # <class '_frozen_importlib.builtinimporter'>import 'encodings.gbk' # <_frozen_importlib_external.sourcefileloader object at 0x00791490>import 'site' # <_frozen_importlib_external.sourcefileloader object at 0x004f73d0>python 3.6.3 (v3.6.3:2c5fed8, oct 3 2017, 17:26:49) [msc v.1900 32 bit (intel)] on win32type help, copyright, credits or license for more information.import 'atexit' # <class '_frozen_importlib.builtinimporter'>1234567891011121314151617
其中关于python的关键信息:
python 3.6.3 (v3.6.3:2c5fed8, oct 3 2017, 17:26:49) [msc v.1900 32 bit (intel)] on win32
“32bit” !!! 一口老血喷出,众里寻他千百度,蓦然回首bug正在这灯火阑珊处。原来是python版本的问题导致的。
修复问题
重新下载一个64bit的python版本,之后重新操作就可以了。
python -v
查看其中的关键信息:
python 3.6.4 (v3.6.4:d48eceb, dec 19 2017, 06:54:40) [msc v.1900 64 bit (amd64)] on win32
确认是64位,没有问题。
然后直接安装tensorflow:
pip3 install tensorflow
安装过程如下:
c:windowssystem32>pip3 install tensorflowcollecting tensorflow downloading tensorflow-1.4.0-cp36-cp36m-win_amd64.whl (28.3mb) 100% |████████████████████████████████| 28.3mb 39kb/scollecting enum34>=1.1.6 (from tensorflow) downloading enum34-1.1.6-py3-none-any.whlrequirement already satisfied: wheel>=0.26 in d:program files (x86)pythonlibsite-packages (from tensorflow)collecting protobuf>=3.3.0 (from tensorflow) downloading protobuf-3.5.1-py2.py3-none-any.whl (388kb) 100% |████████████████████████████████| 389kb 593kb/scollecting tensorflow-tensorboard<0.5.0,>=0.4.0rc1 (from tensorflow) downloading tensorflow_tensorboard-0.4.0rc3-py3-none-any.whl (1.7mb) 100% |████████████████████████████████| 1.7mb 182kb/srequirement already satisfied: six>=1.10.0 in d:program files (x86)pythonlibsite-packages (from tensorflow)collecting numpy>=1.12.1 (from tensorflow) downloading numpy-1.13.3-cp36-none-win_amd64.whl (13.1mb) 100% |████████████████████████████████| 13.1mb 81kb/srequirement already satisfied: setuptools in d:program files (x86)pythonlibsite-packages (from protobuf>=3.3.0->tensorflow)collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow) downloading html5lib-0.9999999.tar.gz (889kb) 100% |████████████████████████████████| 890kb 504kb/scollecting bleach==1.5.0 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow) downloading bleach-1.5.0-py2.py3-none-any.whlrequirement already satisfied: werkzeug>=0.11.10 in d:program files (x86)pythonlibsite-packages (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow) downloading markdown-2.6.11-py2.py3-none-any.whl (78kb) 100% |████████████████████████████████| 81kb 583kb/sbuilding wheels for collected packages: html5lib running setup.py bdist_wheel for html5lib ... done stored in directory: c:userschenjunfeng1appdatalocalpipcachewheelsf85c.b8e1292c6214c4eb73b9dda50f53e8e977bf65989373c962successfully built html5libinstalling collected packages: enum34, protobuf, html5lib, numpy, bleach, markdown, tensorflow-tensorboard, tensorflowsuccessfully installed bleach-1.5.0 enum34-1.1.6 html5lib-0.9999999 markdown-2.6.11 numpy-1.13.3 protobuf-3.5.1 tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc3123456789101112131415161718192021222324252627282930313233
然后大家就可以愉快地写代码了.
总结
问题总在认为不可能的地方发生。如果存在问题,则一定会有原因存在。见或者不见,它都在那里。思考、分析问题与解决是提升的必由之路,通过自由的必经之路。