安裝tensofflow中遇到的坑

-----------------------------------------------------------------------------------

安裝時遇到的坑:

1、yum install  python-pip python-devel,當顯示如下信息:

Installed:
  python-devel.x86_64 0:2.7.5-58.el7                                                                                                
Dependency Updated:
  python.x86_64 0:2.7.5-58.el7                                   python-libs.x86_64 0:2.7.5-58.el7                                  

Complete!

表示成功。

2、執行pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl,提示:

。。。。。。

SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)

說明走https時校驗出了問題,將https改成http再執行,提示:“Successfully installed numpy-1.13.3 protobuf-3.0.0b2 six-1.11.0 tensorflow-0.9.0 wheel-0.30.0”,搞定

參考文章:https://www.cnblogs.com/chenjack/p/6322680.html

-----------------------------------------------------------------------------------------------------------------------------

運行時遇到的坑:

1、RuntimeError: module compiled against API version 9 but this version of numpy is 7

首先下載:wget http://jaist.dl.sourceforge.net/project/numpy/NumPy/1.11.0/numpy-1.11.0.zip
然後解壓:unzip numpy-1.11.0.zip
之後安裝:cd numpy-1.11.0;python setup.py install


2、運行時遇到的坑:RuntimeError: could not open display

解決辦法:在源碼中的import matplotlib as mpl前加兩行代碼,變爲:

import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt

或者直接改文件:/usr/lib64/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc,將backend 配置項改爲Agg

不報錯了,但是也不展示圖像。

進一步解決:先裝tkinter再卸載matplotlib後重裝matplotlib
yum -y install tkinter
pip uninstall -y matplotlib 
pip --no-cache-dir install -U matplotlib

改mpl.use(‘TkAgg’)或backend,提示:_tkinter.TclError: no display name and no $DISPLAY environment variable

後查明,通過secureCRT客戶端登錄是沒法在centos上展現。

最終解決:

mpl.use改回到Agg,不再報錯了。同時,在plt.show()的後面加上一句 plt.savefig('yourfilepath.png')執行完畢後,將png拷貝到自己windows機器上查看。

3、運行程序遇到的坑

執行'module' object has no attribute 'load_csv_with_header'。

解決辦法:執行命令:pip install --upgrade tensorflow。然後重新執行程序,問題解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章