Skip to main content
 首页 » 编程设计

python之IntelliJ 找不到一些生成的 TensorFlow 引用

2024年12月31日23傻小

我用 Python 编写了一些 TensorFlow 代码。它编译并运行良好。但是,IntelliJ 无法解析某些名称。

将鼠标悬停在此类未找到的引用上时显示的错误是 Cannot find reference '...' in 'tensorflow._api.v1.data';展开的消息以 Inspection info: This inspection detects names that should resolve but don't. 开头。

此类未解析引用的一个示例是 tf.data.Dataset。当我导航到 tf.data 时,那里只有一个 __init__.py 模块,它以 # This file is MACHINE GENERATED! 开头.

有很多这样的包,它们在External Libraries 中。解决此问题的正确方法是什么?

请您参考如下方法:

我在 tf.contrib 部分遇到了类似的问题。我用 Anaconda 安装了 TensorFlow 1.10.0 版。它使用 conda 包管理器。安装TF

conda install tensorflow==1.10.0 

使用 Conda 安装解决了我的问题。