简体   繁体   English

"导入“spacy”无法解决 Pylance (reportMissingImports)"

[英]Import "spacy" could not be resolved Pylance (reportMissingImports)

I am new to python and I don't have much experience in constructing a good working directory.我是 python 新手,在构建良好的工作目录方面没有太多经验。 But in my past experience working with installed packages through pip, I don't have any issues.但是在我过去通过 pip 处理已安装软件包的经验中,我没有任何问题。

I am trying to download, install and import spacy.我正在尝试下载、安装和导入 spacy。 According to my pip list, I see the spacy package is successfully downloaded.根据我的 pip 列表,我看到 spacy 包已成功下载。 But when I try to create a python document on MS visual studio code, running the code import spacy<\/code> in my terminal, it says但是当我尝试在 MS Visual Studio 代码上创建一个 python 文档,在我的终端中运行代码import spacy<\/code>时,它说

Import "spacy" could not be resolved Pylance (reportMissingImports).无法解析导入“spacy” Pylance (reportMissingImports)。

<\/blockquote>

When I run it on command, it says:当我在命令上运行它时,它说:

 2021-07-10 15:41:04.164329: W tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-07-10 15:41:04.164530: I tensorflow\/stream_executor\/cuda\/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. INFO:tensorflow:Enabling eager execution INFO:tensorflow:Enabling v2 tensorshape INFO:tensorflow:Enabling resource variables INFO:tensorflow:Enabling tensor equality INFO:tensorflow:Enabling control flow v2<\/code><\/pre>

I wonder if anyone is having a clue on what is going on.我想知道是否有人对正在发生的事情有所了解。

"

You can simply create a requirements.txt<\/code> file where all your installs are listed.您可以简单地创建一个列出所有安装的requirements.txt<\/code>文件。 Every time you add something, update the requirements file by running pip freeze > requirements.txt<\/code> and then when you activate your virtual environment, you can just run py -m pip install -r requirements.txt<\/code> to fix similar issues with missing imports, etc...每次添加内容时,通过运行pip freeze > requirements.txt<\/code>更新需求文件,然后在激活虚拟环境时,只需运行py -m pip install -r requirements.txt<\/code>即可修复缺少导入等类似问题...

"

我设法通过在我正在处理的目录中设置虚拟环境,安装项目所需的包来解决这个问题。

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

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