Why aren't my imports for Python working in VSCode?

陌路散爱 提交于 2020-07-23 00:12:07

问题


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.

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.

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!

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.


Update Post: My Virtual Environment is using my System Python rather than my Venv's Python

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


回答1:


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

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.



来源:https://stackoverflow.com/questions/62548534/why-arent-my-imports-for-python-working-in-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!