Why does PyCharm give unresolved reference errors on some Numpy imports?(为什么 PyCharm 在某些 Numpy 导入时会给出未解决的参考错误?)
问题描述
PyCharm 中的以下行被动态检查标记为每个导入的未解决的参考错误.(它们带有红色下划线.)
The following line in PyCharm is flagged by on-the-fly inspection with unresolved reference errors for each import. (They are underlined red.)
from numpy import tan, arcsin, arccos, arctan
但是,以下导入不会导致任何错误/警告:
However the following imports do not cause any error/warning:
from numpy import sin, cos, arctan2, sqrt, cross, pi
我使用这些导入的代码运行良好,没有任何错误或警告.我通常依靠 PyCharm 的红色错误作为我的代码已损坏且无法运行的警告,但在这种情况下 PyCharm 是错误的.
The code in which I use these imports runs fine without any errors or warnings. I generally rely on PyCharm's red errors as a warning that my code is broken and will not run, but in this case PyCharm is wrong.
为什么 numpy 的一些函数能被 PyCharm 的内省识别而另一些不能?
Why are some of numpy's functions recognized by PyCharm's introspection and others aren't?
当前版本:
- Windows 7 64 位
- Python 2.7.5
- PyCharm 3.1.2
- Numpy 1.8
谢谢!
推荐答案
你得到这个的原因是因为 PyCharm 的静态分析.现在,Python 所做的是使用静态骨架(有些是预先生成的,有些是生成的)来为您提供分析.看看这里的预生成骨架 -> https://github.com/JetBrains/python-skeletons
The reason you are getting this is because of PyCharm's static analysis. Now, what Python does is use static skeletons (some are pre-generated and some are generated) to give you the analysis. Take a look at the pre-generated skeletons here -> https://github.com/JetBrains/python-skeletons
这可以通过启用以下功能来解决:
This might be solved, by enabling the following:
但是,如果这不起作用:
However, if that does not work:
这将阻止错误,它将显示为行上方的注释.
which will block off the error, it will appear as a comment above the line.
这篇关于为什么 PyCharm 在某些 Numpy 导入时会给出未解决的参考错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 PyCharm 在某些 Numpy 导入时会给出未解决的
基础教程推荐
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
