前言 因为要运行网上的代码,环境要求低版本 python 和 tensorflow,本以为 so easy,没想到遇到的问题还不少,记录一下,希望能帮到大家~
问题1
我创建完虚拟环境后想查询一下 python 版本,输入python -v ,就会输出一大堆,具体啥意思我也不知道。  然后输入python -version ,提示输入pytho -h ,可见Python -version 不能查询 python 版本。还是直接输入python 就行。  
问题2
其实创建虚拟环境的时候已经知道 python 版本了,但正是由于问题2导致我去查询 python 版本进而产生问题1了。
当我在 python2.7 环境中安装 tensorflow 1.x 时,总是会报下面这样的错:
Could not find a version that satisfies the requirement tensorflow == 1.4.0 (from versions: ) No matching distribution found for tensorflow==1.4.0
(图源网络,侵权立删。水印弄不掉了,前几天还行的,不知道官方弄得啥东西……)  原来是因为 tensorflow 目前已经不能在python2.7中安装了,只支持3.6和3.7。
如果想要在低版本 python 中安装 tensorflow,只能先下载对应的 whl 文件然后再 pip 安装。不过因为我没找到适合 python2.7 的 tensorflow1.4.0,所以改下 tensorflow1.5.0 了。
(1)到这个网址中下载工具包tensorflow1.4,https://github.com/fo40225/tensorflow-windows-wheel  依次进入目录1.5.0/py27/CPU/avx2,下载该目录下的工具包即可。  【注】py2.py3就是python2和3都可以支持,其他的包找对应的python2的版本就可以了。
下载完成后,在终端下进入该工具包所在目录输入如下指令即可:
pip install tensorflow-1.5.0-cp27-cp27m-win_amd64.whl
然后pip list 检查一下,就能看见tensorflow安装成功啦:) 
我看网上还有帖子说是因为pip指令没有指定镜像源,源自网络:这种情况,anaconda会从默认的源中下载,然而tensorflow默认源中的2.0以下的版本都废弃无法安装,所以要安装低版本tensor就要指定镜像源。
我试了以后发现没起作用,大家可以试试看。 原文链接
Reference: 1、https://blog.csdn.net/weixin_42427230/article/details/122477411 2、https://blog.csdn.net/Joseph__Lagrange/article/details/103706243
|