Strange error with Keras and Spyder

时光毁灭记忆、已成空白 提交于 2020-08-07 01:32:22

问题


I'm using Spyder to do some small projects with Keras, and every now and then (I haven't pinned down what it is in the code that makes it appear) I get this message:

  File "~/.local/lib/python3.5/site-packages/google/protobuf/descriptor_pb2.py", line 1771, in <module>
    __module__ = 'google.protobuf.descriptor_pb2'

TypeError: A Message class can only inherit from Message

Weirdly, this exception is not raised if I execute the program outside of Spyder, using the terminal. I've looked around and I have found no one who has encountered this error while using Keras.

Restarting Spyder makes it go away, but it's frustrating. What could be causing it?


回答1:


I had the same problem with Spyder, which happened when it was trying to reload modules that were already loaded. I solved it by disabling the UMR (User Module Reloader) option in "preferences -> python interpreter" .




回答2:


Ok, I found the cause: interrupting the execution before Keras fully loads.

As said before restarting Spyder (or just the console) solves it.




回答3:


Restarting Sypder works or run your script using console only. Don't forget to use at the top:

from google.cloud import bigquery
from google.oauth2 import service_account
from google.auth.transport import requests


来源:https://stackoverflow.com/questions/45894208/strange-error-with-keras-and-spyder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!