tensorflow踩坑
1.
.
在pip中直接install tensorflow,出现阅读timed out的错误,可能是安装源下载较慢,可以更换源为国内的镜像源,例如:
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/ 。
命令行输入:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
如果还是不行,可能是网络太慢,可以再更换源的同时延长timeout时间。
命令行输入:pip --default-timeout=100 install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
如果这样还是不行,可能是网络实在不灵,例如我上面截图中的情况。然后我试着把笔记本从卧室换到客厅让WiFi信号强一点,重新下载安装就成功了。
2.安装完成以后,在pycharm中直接运行tensorflow报错:运行TensorFlow代码报错ImportError: Could not find the DLL(s) 'msvcp140_1.dll'。需要下载vc。到网站https://support.microsoft.com/zh-cn/help/2977003/the-latest-supported-visual-c-downloads下载相应计算机文件,点击安装即可。
3.然后继续运行接着报错,导入TensorFlow模块后报错''ImportError: DLL load failed: 找不到指定的模块''。这个是最关键的问题:有的笔记本比较老,它的CPU不兼容tensorflow,所以就需要卸载高的版本,安装低的版本:
pip uninstall tensorflow
pip install tensorflow==1.5 -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
然后接着报错,神奇的是继续pip install protobuf 然后运行成功