简体   繁体   English

无法从 sklearn 导入方法(使用 VSCode)

[英]cannot import a method from sklearn (using VSCode)

I'm using VSCode, and I import KDTree like this我正在使用 VSCode,我像这样导入 KDTree

from sklearn.neighbors import KDTree

while the KDTree stays in white(which means VSCode cannot find this method)而 KDTree 保持白色(这意味着 VSCode 找不到此方法)

I'm using python3.8 on my Linux and 3.9 on my Mac我在我的 Linux 上使用 python3.8,在我的 Mac 上使用 3.9

addtional info : I've installed sklearn, and I checked init .py file in sklearn.neighbors附加信息:我已经安装了 sklearn,并检查了 sklearn.neighbors 中的init .py 文件

It looks like this sklearn.neighbors init .py它看起来像这个sklearn.neighbors init .py

Why the KDTree parts stays in white?为什么 KDTree 部分保持白色?

If KDTree is not highlighted in the expected color, it doesn't mean VS-Code could not find this method.如果KDTree没有以预期的颜色突出显示,这并不意味着 VS-Code 找不到该方法。 It could just mean that you have not accessed this method yet in your program.这可能只是意味着您尚未在程序中访问此方法。 Try creating a KDTree object, it should work as expected.尝试创建一个KDTree对象,它应该可以按预期工作。

Note that if you haven't installed "sklearn" yet, you would need to install it first before using sklearn.KDTree .请注意,如果您尚未安装“sklearn”,则需要在使用sklearn.KDTree之前先安装它。

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

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