zoukankan      html  css  js  c++  java
  • 【bug】【Cannot find reference 'imread' in '__init__.py | __init__.py'】

    pycharm开启了代码智能提示,opencv模块正确导入了,代码可以正常运行,但是,会有

    Cannot find reference 'imread' in '__init__.py | __init__.py'

    的warning,而且没有代码提示,不能获取documentation,也不能查看源码,不能提示形参列表,排查了很久,不知道为何。

    找到一个相关的问题:

    python - Cannot find reference 'xxx' in init.py - Stack Overflow

    不是很理解

    PyCharm looks at the __init__.py file to traceback to the module where a function/variable resides. So without __all__ having the modules names, it can't traceback to the source.

    我的推测也是pycharm这样做并不是bug,而是根据__init__.py文件中的__all__全局变量来进行索引。

    关闭这个warning是简单的,但没有必要,而且即使关闭warning,代码提示功能依旧不起作用。

    后面我通过修改opencv的版本,完美的解决了这个问题,没有warning,并且代码提示功能也正常了。

    有问题的版本是

    可以看到其__init__.py文件中的__all__变量声明

    居然是空的,不清楚到底原因是不是因为这个__all__

    之后我修改了opencv的版本,改为4.5.3.56,问题解决了

  • 相关阅读:
    P1744 采购特价商品
    P1359 租用游艇
    P3092 [USACO13NOV]没有找零No Change
    P1272 重建道路
    P2014 选课
    P1026 统计单词个数
    P1776 宝物筛选_NOI导刊2010提高(02)
    自定义异步非阻塞tornado框架
    tornado进阶篇
    tornado基础篇
  • 原文地址:https://www.cnblogs.com/ericling/p/15502933.html
Copyright © 2011-2022 走看看