This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python scripts are executed with the wrong path separator in integrated Powershell on Windows #13811
Comments
@tsbertalan, thanks for letting us know about this. We'll take a look and get back to you as soon as possible. |
Is this issue still happening with the latest version of the extension? |
Yes, I'm usually running on Ubuntu these days (or, if on Windows, using the remote feature over SSH), so I don't bump up against this. However, I uninstalled and reinstalled the Python, Jupyter, and Pylance extensions just now (Python extension is now at v2021.3.680753044). I still see all-backslashes when running a script in debug mode, but, in run mode, backslashes in the prompt and forward slashes in the python.exe and BLAH.py path to the right of the prompt. |
@tsbertalan Thanks for the prompt response. We think the general solution on how to launch scripts should come from VSCode, microsoft/vscode#108550. I'm converting this to a feature request under Github discussions to see how many users face this issue. My initial gut says that you seem to have a very special case where the way script is launched is important to you, but for most users it isn't so unfortunately I don't see us prioritizing to fix it ourselves. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Environment data
python.languageServer
setting: JediExpected behaviour
On Windows, with Powershell as the embedded terminal, the path to the python executable and to the current script being executed should use backslashes.
Actual behaviour
A script command line like this is generated:
However, invoking
workbench.action.debug.start
instead generates:Which was very confusing at first--when I debugged the script, paths which were constructed using
os.path.join
withos.path.basename(__file__)
had homogeneous, all-backslash paths, but when I ran it withpython.execInTerminal
, the paths were mixed!Steps to reproduce:
C:\Users\USERNAME\Anaconda3\envs\ENVNAME
.python.execInTerminal
(the little play button) to launch a script, withterminal.integrated.shell.windows
unset (that is, left to its default ofC:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
).I'm currently working on a script that uses
os.path.join
,os.path.basename
, etc., and in particular usesbasename(__file__)
to get the path of the current script in a cross-platform way. This does intelligently interprets the forward slashes as path separators, and trims off theSCRIPT.py
part, leaving aC:/Users...
path. But then, subsequentjoin
s with this path have mixed slashes, sincejoin
correctly uses backslash as a path separator on windows.This isn't a problem for my script at the moment, since all file-access code (for instance, these mixed-slash paths are being passed to
glob.glob
) seems to be intelligently homogenizing the slashes. But it could become a problem in the future.The text was updated successfully, but these errors were encountered: