模块 'tensorflow' 没有 '__version__' 成员 pylint(无成员)

Module 'tensorflow' has no '__version__' member pylint (no-member)

我刚刚安装了 Tensorflow 并尝试打印我安装的版本。

import tensorflow as tf
print(tf.__version__)

当我得到这个时 'error':

Module 'tensorflow' has no '__version__' member pylint (no-member)

我说错误是因为它向终端打印 2.0.0 但 VSCode 仍然说文件中有错误。我认为这可能是 linter 的问题,但我已经安装了 pylint,这就是 TF recommends.

关于如何修复此错误的任何想法?在添加参数以禁用此类错误之前,我更愿意知道是什么原因造成的。

看来我检查版本的方式不正确。取a look at the docs应该是:

import tensorflow as tf
print(tf.version.VERSION)