简体   繁体   English

为什么 PyCharm 无法正确识别某些 python 库?

[英]Why does PyCharm can't recognize certain python libraries correctly?

For example, this line of code:例如,这行代码:

from distutils.command.build_ext import build_ext

I can import it correctly from a terminal python interpreter, but in PyCharm, it displays a red flag on 'build_ext', which says 'can't find reference 'build_ext' in 'build_ext.pyi'.我可以从终端 python 解释器正确导入它,但是在 PyCharm 中,它在“build_ext”上显示一个红色标志,上面写着“在“build_ext.pyi”中找不到参考“build_ext”。

Why is that?这是为什么?

check the version of the distutils by print(distutils.__version__) in the terminal.在终端中通过print(distutils.__version__)检查distutils的版本。 And install that version of the distutils in your python environment.并在您的 python 环境中安装该版本的distutils pip install distutils==version
this seems like a version mismatch.这似乎是版本不匹配。 so, some functions in the library will change or obsolete.因此,库中的某些功能将更改或过时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM