Support shebang #!/usr/bin/env python{2,3}
See original GitHub issueOne 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:
#!/usr/bin/env python3
import sys
print(sys.executable)
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
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Why do people write #!/usr/bin/env python on the first line of a ...
In computing, a shebang (also called a hashbang, hashpling, pound bang, or crunchbang) refers to the characters "#!" when they are the first...
Read more >Make Linux/Unix Script Portable With #!/usr/bin/env ... - nixCraft
Learn how to make Linux/Unix script portable with #!/usr/bin/env shebang to execute script using the interpreter such as bash, perl, python.
Read more >On Python Shebangs – Michael Catanzaro's Blog
Let's first set aside the python2/python3 issue and focus on whether to use env. Which of the following is correct? #!/usr/bin/env python #!/usr ......
Read more >1269952 – python scripts using #!/usr/bin/env python shebang ...
Description of problem: Python scripts have #!/usr/bin/env python will fail to execute in Fedora 23 Version-Release number of selected ...
Read more >Default to python3 for '/usr/bin/env python' - Ask Ubuntu
That's because env is searching python in your PATH , not on any shell builtin, or alias or function. As you have defined...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As I said in #3689, this is perfectly reasonable default behavior, but the option to enable such automatic functionality would be great.
Ok, looks like you are not using the Python extension to run the python program. You seem to be using another extension such as
Code Runner
. I’m closing this issue as the output of the output panel is a clear indication of the above fact.Solution is to use the debug menu or the corresponding debug icons (F5 or CTRL+F5 or similar).