Python问题记录

源问题

  1. windows 换源
    pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
    
    

pip报错问题

  1. pip install PIL 报错:

    ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)                                                      
    ERROR: No matching distribution found for PIL
    

    原因: 引用stackoverflow用户FogleBird的回答:

    Use Pillow instead, as PIL is basically dead. Pillow is a maintained fork of PIL.

    解决方法:

    pip install Pillow
    

    在使用时仍然

    import PIL
    

    即可

Matplotlib问题

  1. 解决关于 UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.plt.show()的报错。
    原因: AGG后端不支持GUI界面,切换后端即可
    步骤:
    matplotlib backend列表
    ~/.config/matplotlib/matplotlibrc(没有就创建)里添加如下内容:

    backend : Qt5Agg #或上述连接==链接里的其他交互式backend
    

    或者在自己的源码里添加

    	matplotlib.use('Qt5Agg')
    

    并安装相应的依赖库

    pip install PyQt5 #或上述链接里找到的其他backend的相应依赖
    

    此时就能正常使用了

keras问题

  1. 修改keras的backend
    在~/.keras/keras.json里添加如下内容
    {
    "image_dim_ordering": "tf", 
    "epsilon": 1e-07, 
    "floatx": "float32", 
    "backend": "tensorflow"
    }
    

版权声明:本文为qq_41923036原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。