-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support shebang #!/usr/bin/env python{2,3} #497
Comments
There should be a code lens in the latest version of the extension that you can click to switch the selected Python interpreter to the interpreter in the shebang. But we purposefully don't not automatically select what the shebang sets because what someone set for their code may not be what you want to use (e.g. you might choose Python 3.5 but I want to run against 3.6, or you hard-coded the path on Linux and thus doesn't work on Windows). |
Please could you go into |
By 'version selected' re: my screenshot above, I mean the version selected in the 'Python: Select Interpreter'. I've also just checked the local workspace, added it, and it does not work in a local workspace nor is it respected in global settings. |
@citizenrich |
Sure. So, sorry if I've not been clear. The 'Python: Select Interpreter' is already set. On workspace settings, I've tried it with no workspace settings. And with (macOS homebrew installed Python 3):
|
Ok, looks like you are not using the Python extension to run the python program. You seem to be using another extension such as Solution is to use the debug menu or the corresponding debug icons (F5 or CTRL+F5 or similar). |
As I said in #3689, this is perfectly reasonable default behavior, but the option to enable such automatic functionality would be great. |
One of the best practices for managing Python versions across operating systems is the shebang '#!/usr/bin/env python3'. To get around the lack of support for this practice, it seems that the user has to add changes to each individual workspace to set Python versions. Note that setting the 'Python: Select interpreter' is also ignored by VSCode.
It would be helpful if maintainers were transparent about whether they have interest or will accept a PR from someone else contributing a fix. This issue was closed in the upstream repo multiple times and not left as open.
Actual behavior
shebang is ignored
Expected behavior
shabang is respected
Steps to reproduce:
Create file:
Run it.
Environment data
VS Code version: 1.19.1
Python Extension version: 0.9.1
Python Version: 3.6.4
OS and version: macOS 10.13.2
The text was updated successfully, but these errors were encountered: