尝试 MNIST 数据集时 tensorflow 和 matplotlib 包出现问题



我正在尝试使用tensorflow进行MNIST数据集作为练习,并且在软件包方面遇到了一些问题。我正在使用 Pycharm 2019.3.1。 这是我的代码:

import tensorflow as tf
import matplotlib.pyplot as plt
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
image_index = 7777
print(y_train(image_index))
plt.inshow(x_train(image_index))

我收到"没有模块称为tensorflow"和"没有模块称为 matplotlib"错误。

上述错误表明您尚未在系统中安装张量流和 matplotlib 库。您可以创建一个虚拟环境或 conda 环境,并激活该环境,安装上述库并在新创建的虚拟环境或 conda 环境中运行上述 python 程序。