microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.31k stars 1.18k forks source link

Unable to identify Python executable from path due to apostrophe #24265

Open jacobopt opened 5 days ago

jacobopt commented 5 days ago

Discussed in https://github.com/microsoft/vscode-python/discussions/24264

Originally posted by **jacobopt** October 7, 2024 Hello, Posting to Github because I was directed here from Stack Overflow! I have a user who is not able to get VSCode to recognise the Python executable from the Python path. We have set the default interpreter path to be the path of the executable in the extension settings, but it's still not working. We suspect the issue is to do with an apostrophe in the path, due to the name of the user containing an apostrophe. The path of the executable is this: `C:/Users/BobO'Ross/AppData/Local/Programs/Python/Python312/python.exe` and the error message we get after trying to run a Python program is this: `The term C:/Users/BobORoss/AppData/Local/Programs/Python/Python312/python.exe c:/Users/BobORoss/Documents/test1.py' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.` As you can see, the error message removes the apostrophe from the directory. It probably does this because it sees the apostrophe as a special letter. We have tried escaping the apostrophe in various ways e.g. by adding a backslash and a ` (whatever that character is called), but none of these seem to work. We're not really sure what else to do. Thank you in advance for your help.
karthiknadig commented 3 days ago

This looks like a bug in the shell escaping.

@Tyriar This is something that we often run into where sendText fallback also fails because we don't know shell type or we can't do shell escaping correctly.