与 Poetry 一起安装的软件包无法导入
有一个简单但令人困惑的问题:当我尝试在模块中使用我用诗歌添加的包时,它无法导入。采取的步骤:
poetry add sendgrid
- 在模块中,
import sendgrid
- 错误:
导入“sendgrid”无法解析 PylancereportMissingImports
我尝试过的故障排除:
- 我检查了我的项目的诗歌 venv 目录,并且 sendgrid 在那里:
'C:\\Users\\xyz123\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\nameofproject-py3.10\\lib\\site-packages'
- 还检查了 sys 。小路();列出了该 site-packages 目录的路径
- 运行
poetry install
给了我响应No dependency to install or update
- pyproject.toml和poetry.lock文件列表sendgrid
到底是怎么回事?
Having a simple yet confusing issue: a package I added with poetry fails to import when I try to use it in a module. Steps taken:
poetry add sendgrid
- In a module,
import sendgrid
- Error:
Import "sendgrid" could not be resolved PylancereportMissingImports
Troubleshooting I've tried:
- I checked my project's poetry venv dir, and sendgrid is there:
'C:\\Users\\xyz123\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\nameofproject-py3.10\\lib\\site-packages'
- Also checked sys.path(); the path to that site-packages dir is listed
- Running
poetry install
gives me the responseNo dependencies to install or update
- both the pyproject.toml and the poetry.lock files list sendgrid
What is going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,事实证明这是 VSCode 运行不佳并且无法识别 Poetry 虚拟环境的问题。我必须运行
Python: Select Interpreter
命令并将 venv 目录更改为我的项目正在使用的目录,然后它才能识别已安装的软件包。有关操作方法的更多详细信息,请参阅此处那。
Well, it turns out it's a matter of VSCode not playing nice and failing to recognize Poetry's virtual environment. I had to run the
Python: Select Interpreter
command and change the venv directory to the one my project is using, then it was able to recognize the installed packages.See here for more details on how to do that.