Open Akopov4 opened 1 month ago
Thanks for the issue. Pylance doesn't actually handle debugging of Python code. Transferring.
@Akopov4 You see an issue when you run or you see it with handling of imports in the editor?
it's not an issue, it's feature request
@karthiknadig
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
without it, when a user tries to run python file
in debugger
, import
statement rooted from workspace root
won't be resolved at runtime even if it is resolved at editing
time due to our import resolve heuristic.
root/
lib/
__init__.py
module.py
currentfile.py
currentfile.py
import module # this will work at runtime and edit time
import lib.module # this won't work at runtime but will work at edit time.
user might want it to just work when debugging?
that said, if user run currentfile.py
from terminal
, it still won't work unless user add root
to sys.path
in some ways such as setting PYTHONPATH
env var or sys.path.append(...)
from code.
user could use .env
for it to be set on terminal
but when user run it in regular command line
it won't work again.
but it will at least make it to just work for debugger?
maybe "PYTHONPATH": "${workspaceFolder};${env:PYTHONPATH}",
would be better for reason that there were already PYTHONPATH environmental variable set
@heejaechang usually directories like .vscode, .idea and so on are included in gitignore file. So they don't affect production codes. This configuration is used by debugger and by "Run python file" in the editor. Soultion of @V4n1sh is better then my one
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.
I support this feature request, in general I think we can do better with out-of-the-box experience - I was surprised how much effort and setup it takes to just start debugging any Python code in VSCode for a new project as opposed to PyCharm where it "just works".
Hi, I'm new User of VScode. Previously I used Jetbrains Pycharm and not for a long time ago switched to VSCode. Please add "env": { "PYTHONPATH": "${workspaceFolder};${env:PYTHONPATH}" } as default configuration parameters, when create to launch.json Pycharm did it for a long time ago Thank you in advance