question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support shebang #!/usr/bin/env python{2,3}

See original GitHub issue

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:

#!/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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
spencerhakimcommented, Dec 14, 2018

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

As I said in #3689, this is perfectly reasonable default behavior, but the option to enable such automatic functionality would be great.

0reactions
DonJayamannecommented, Jan 3, 2018

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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found