This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: #!/usr/bin/python shebang doesn't use default python (3) on Windows
Type: Stage: resolved
Components: Windows Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: py.exe ignored PATH when using python3 shebang
View: 28686
Assigned To: Nosy List: fireattack, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2020-02-28 18:15 by fireattack, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg362892 - (view) Author: fireattack (fireattack) * Date: 2020-02-28 18:15
STR

1. Install both Py2 and 3. 
2. Make sure Py3 is the default.
3. (Optional) Make sure only Python3 is in path, not Python2.

Run the following script from CMD:

```
#!/usr/bin/python

import platform
print(platform.python_version())
```

What expected:

3.8.1

What happened: 

2.8.5

According to https://docs.python.org/3/using/windows.html#shebang-lines, `#!/usr/bin/python` should use the default python. My environment is set to default to py3, and I don't even have python2 in my PATH. 

C:\Users\ikena\Desktop>py --version
Python 3.8.1

C:\Users\ikena\Desktop>python --version
Python 3.8.1

C:\Users\ikena\Desktop>where python
C:\Users\ikena\AppData\Local\Programs\Python\Python38\python.exe
C:\Users\ikena\AppData\Local\Microsoft\WindowsApps\python.exe
msg362893 - (view) Author: fireattack (fireattack) * Date: 2020-02-28 18:18
I've searched and found some related issue, but none is specific for this. 

For example, Segev Finer mentioned that "[..] "#!/usr/bin/python" which will prefer Python 2" in issue 34274 but didn't mention why it would/should.
msg362895 - (view) Author: fireattack (fireattack) * Date: 2020-02-28 18:24
Interestingly, I can't seem to reproduce this bug on my another Win7 machine with similar setup.
msg362896 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-02-28 18:29
This is not strictly a duplicate of issue28686, but it's close enough, so let's keep the discussion of changing the original shebang behaviour over no that issue.
History
Date User Action Args
2022-04-11 14:59:27adminsetgithub: 83966
2020-02-28 18:29:16steve.dowersetstatus: open -> closed
superseder: py.exe ignored PATH when using python3 shebang
messages: + msg362896

resolution: duplicate
stage: resolved
2020-02-28 18:24:33fireattacksetmessages: + msg362895
2020-02-28 18:21:06fireattacksettitle: usr/bin/python doesn't use default python (3) on Windows -> #!/usr/bin/python shebang doesn't use default python (3) on Windows
2020-02-28 18:18:53fireattacksetmessages: + msg362893
2020-02-28 18:15:33fireattackcreate