为什么我的Python导入无法在VSCode中工作? [英] Why aren't my imports for Python working in VSCode?

查看:371
本文介绍了为什么我的Python导入无法在VSCode中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我对Python以及VSCode(最近从Atom迁移过来)的世界都是陌生的.我还要说的是,我正在使用运行MacOS Catalina的 2014年初的MacBook Air .我真的很喜欢VSCode!在许多方面都令人赞叹,但这……还不太清楚.

First of all, I am new to both Python as well as the world of VSCode (recently moved over from Atom). I will also say that I am using an Early 2014 MacBook Air running macOS Catalina. I really do love VSCode! It's amazing in many ways, but this... this is just too unclear.

好的,我几乎尝试了所有操作,而且我不明白为什么我的导入无法正常工作!我在Github上查看了有关该问题的文档(我会说我可能在目录中有一些错误的地方,指的是文档).我已经尝试过"python.autoComplete.extraPaths": [],了.我尝试过更改(虚拟)环境,当然,我自己也设置了一个新环境.我尝试将"python.languageServer:"设置为Jedi并返回到Microsoft.我什至找不到所有人都告诉我的"python.jediEnabled: false"评论.

Okay, I have tried literally almost everything and I don't understand why my imports won't work! I have looked at the documentation on the issue on Github (I will say I may have something with the directory wrong there, referring to the docs). I have tried the "python.autoComplete.extraPaths": [], thing. I have tried changing my (virtual) environment and, of course, setting up a new one myself. I have tried setting "python.languageServer:" to Jedi and back to Microsoft. I can't even find the "python.jediEnabled: false" comment that everybody is telling me to uncomment.

但是,我的导入仍然是静止 未解决(Microsoft语言服务器)" 未找到(终端)" 无法导入(Pylint)" .只是让我如此生气,我不明白自己做错了什么!

Yet, my imports are still "unresolved (Microsoft language server)" or "not found (Terminal)" or "unable to be imported (Pylint)". It just makes me so angry and I don't understand what I've done wrong!

我已经看到像pygamerequests这样的模块在VSCode上对于许多其他模块(YouTube)来说都可以正常工作,但是我的模块尚未起作用.

I've seen modules like pygame and requests work just fine on VSCode for many others (YouTube), yet mine has yet to work.

有人可以告诉我我显然不知道的秘密吗?谢谢.

Can someone please tell me the secret that I don't apparently know? Thanks.

更新发布:我的虚拟环境正在使用系统Python,而不是Venv的Python

感谢您(到目前为止)所提供的帮助.我离解决这个问题越来越近了. ^-^

Thank you for everyone who has helped (so far). I am getting a lot closer to solving this. ^-^

推荐答案

他们已删除了"python.jediEnabled"设置而不是"python.languageServer",则可以引用这里.

They had removed "python.jediEnabled" setting instead of "python.languageServer", you can refer to here.

也许您没有安装要导入的软件包,因为您使用了错误的"pip".选择正确的环境后,您需要激活它(Ctrl + Shift +`),否则,您将使用错误的'pip'.您可以输入"pip --version"来检查您正在使用的"pip".然后,您可以尝试安装要导入的软件包.

Maybe you haven't installed the package which you want to import, because you had used the wrong 'pip'. When you select the right environment, you need to activate it(Ctrl+Shift+`), otherwise, you'd use the wrong 'pip'. You can type 'pip --version' to check which 'pip' you are using. Then you can try to install the package you want to import.

这篇关于为什么我的Python导入无法在VSCode中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆