Python 属性错误:模块';tensorflow';没有属性';名称范围';

Python 属性错误:模块';tensorflow';没有属性';名称范围';,python,csv,tensorflow,keras,module,Python,Csv,Tensorflow,Keras,Module,我一分钟前刚刚运行了这个程序,它的工作方式应该是这样的。现在它返回这个错误,我不知道是什么引起的。 这是我的密码: import csv import numpy as np import tensorflow as tf from keras.models import Sequential from keras.layers import Dense, Flatten, Activation from keras.layers import Dropout from keras.layers

我一分钟前刚刚运行了这个程序,它的工作方式应该是这样的。现在它返回这个错误,我不知道是什么引起的。 这是我的密码:

import csv
import numpy as np
import tensorflow as tf
from keras.models import Sequential
from keras.layers import Dense, Flatten, Activation
from keras.layers import Dropout
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from tensorflow.keras import utils

train_imgs=[]
a=[]
b=[]
with open('train.csv', 'r') as csv_file:
    csv_reader=csv.reader(csv_file)
    next(csv_reader)
    for line in csv_reader:
        for i in line[0]:
            i=int(i)
            a.append(i)        
train_labels=utils.to_categorical(a, 10)
class_names = ["Злость", "Отвращение", "Страх", "Радость", "Грусть", "Удивление", "Нейтральная эмоция"]
下面是错误:
AttributeError:module'tensorflow'没有属性'name\u scope'

正如你所看到的,在代码的这一特定部分中,我没有使用tensorflow,这与name_scope是一样的。另外,当我删除keras及其模块的导入时,我并没有得到这个错误,但我需要keras,所以问题并没有得到解决。
有人知道怎么修吗?

好的,我试了一下,它确实起了作用

pip install --ignore-installed --upgrade tensorflow==1.14.0

可以解决您的问题您使用的是什么版本的tf和KERA?