1. 程式人生 > >TypeError: __init__() got an unexpected keyword argument 'serialized_options'

TypeError: __init__() got an unexpected keyword argument 'serialized_options'

更新TensorFlow引起的慘案。。。

忘了是因為什麼原因,我更新了一波TensorFlow,然後在P本地Python中import TensorFlow時,就報出了這個錯誤。

網上的原因是說protobuf版本不對,採用

pip install -U protobuf

安裝時,發現在我的電腦上的protobuf已經安裝,所以沒有什麼反應。

我啟用TensorFlow環境,使用Python,import TensorFlow,發現可以匯入,不報錯。

import protobuf,報錯no module named protobuf.

然後在TensorFlow環境中解除安裝protobuf,發現protobuf版本號為3.2.0

使用pip install protobuf,安裝了3.6.0版本的protobuf。

退出TensorFlow,發現protobuf的版本也為3.6.0.

本地Python和TensorFlow環境下均解除安裝protobuf3.6.0,安裝protobuf3.2.0.

然而在本地Python中,還是出現了import TensorFlow 報錯,還是之前的錯,所以這樣來看protobuf版本問題並沒有起作用。

進一步檢視,發現本地安裝的TensorFlow版本為1.12.0,而TensorFlow環境下安裝的TensorFlow版本為1.2.1.

在本地解除安裝1.12.0的TensorFlow,安裝1.2.1的TensorFlow。

在cmd下import TensorFlow不報錯,在Spyder中匯入報錯:NameError: name 'core' is not defined

重新匯入的時候又報錯:沒有找到Python。

重啟一下kernel,import TensorFlow成功。

總結一下:個人覺得還是TensorFlow版本錯誤的原因,可能是我剛開始又安裝了TensorFlow,才導致這樣的折騰。