简体   繁体   English

Linux 上 VS 代码中的 Python 路径

[英]Python path in VS Code on Linux

So, this has been covered a number of times already, and there's some good documentation on how things are supposed to work here .所以,这已经被讨论过很多次了,并且有一些很好的文档说明这里应该如何工作。 Except: nothing seems to work for me, How do I debug this?除了:似乎没有什么对我有用,我该如何调试? what am I missing: I've tried the following things:我错过了什么:我尝试了以下事情:

  • set PYTHONPATH in .env in the root of my workspace在我工作区的根目录中的.env中设置PYTHONPATH
  • add "python.envFile": ".env" to .vscode/settings.json添加"python.envFile": ".env".vscode/settings.json
  • move .env to .vscode/env , update python.envFile to reflect.env移动到.vscode/env ,更新python.envFile以反映
  • remove all the env business, add python.autoComplete.extraPaths to .vscode/settings.json删除所有env业务,将python.autoComplete.extraPaths添加到.vscode/settings.json
  • use a workspace config with a settings key, repeat the steps above使用带有settings键的工作区配置,重复上述步骤
  • just give in and run PYTHONPATH=directory code.只需放弃并运行PYTHONPATH=directory code.

All of the above is completely ignored, pylint keeps on complaining.以上所有内容都被完全忽略了,pylint 一直在抱怨。 I am getting a bit frustrated.我有点沮丧。 What am I missing here!我在这里错过了什么!

Right, cause found.对了,找到原因了。 Even outside of VS Code pylint was acting up.甚至在 VS Code pylint之外都在发挥作用。 Source of the problem: the top-level dir also contained an __init__.py file, messing up all sorts of things.问题的根源:顶级目录还包含一个__init__.py文件,搞砸了各种事情。 Remove that file and it starts working...删除该文件,它开始工作......

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

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