I'm new to both VS Code and Python, so I apologize if this is already possible, but for the life of me I couldn't see how to change this.
I'm using:
VS Code (Win) v1.42.0
vscode-python v2020.2.62710
Example: I open mypythonscript.py
file in a custom directory, say C:\Users\username\Documents\Python\Test
. I then open the Python REPL, and it only ever opens the terminal with current working directory set to C:\Users\username
, so if I try to import the current file using import mypythonscript
, it fails. I'd really like the REPL to open in the directory of the currently open file/project if possible.
I can do this with the terminal itself by setting terminal.integrated.cwd
to ${fileDirname}
, but this has no effect on the terminal that the python extension opens. I've tried enabling python.terminal.executeInFileDir
but this doesn't help.
Is there a way to do this, or do I need to submit an enhancement request? It seems like such a logical thing to want to do, that if it's not possible I'd even go as far as call it a bug.