简体   繁体   English

无法从 sklearn.feature_extraction.text 导入 CountVectorizer

[英]Cannot import from sklearn.feature_extraction.text import CountVectorizer

I'm trying to import CountVectorizer from sklearn with the following line:我正在尝试使用以下行从sklearn导入CountVectorizer

from sklearn.feature_extraction.text import CountVectorizer

  • sklearn: 0.0学习:0.0
  • scikit-learn: 0.23.2 scikit-学习:0.23.2
  • numpy: 1.19.2麻木的:1.19.2
  • scipy: 1.5.2科学:1.5.2
  • threadpoolctl: 2.1.0线程池ctl:2.1.0
  • joblib: 0.17.0作业库:0.17.0

Every time I try to run the code I receive the following error:每次我尝试运行代码时,我都会收到以下错误:

No name 'feature_extraction' in module 'sklearn' pylint(no-name-in-module)

Unable to import 'sklearn.feature_extraction.text' pylint(import-error)

If it matters I am running this in vscode on a Linux system inside of a VM.如果重要的话,我会在 VM 内的 Linux 系统上的 vscode 中运行它。 Also, I was able to run it earlier on the VM and it just stopped working for no apparent reason.此外,我能够更早地在 VM 上运行它,但它只是无缘无故地停止工作。

I found out the reason why for some reason my vscode was saving my file as .pyc and it wouldn't recognize the library with pyc.我发现了为什么我的 vscode 出于某种原因将我的文件保存为 .pyc 并且它无法识别带有 pyc 的库的原因。 If anyone else experiences this problem note my file still said py but auto-generated a pycache folder.如果其他人遇到这个问题,请注意我的文件仍然说 py 但自动生成了一个pycache文件夹。

because sklearn is deprecated try this:因为 sklearn 已被弃用,请尝试以下操作:

pip install scikit-learn

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

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