# The \`python\` command should be permanently reserved for Python 2

**URL:** <https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031>\
**Category:** Python\
**Created:** [April 15, 2019, 7:32pm UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031 "2019-04-15T19:32:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zackw](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/zackw/32/1594_2.png) [@zackw](https://travis-ci.community/u/zackw)\
**Post date:** [April 15, 2019, 7:32pm UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/1 "2019-04-15T19:32:02Z")

</div>

Regarding the update to the default version of Python:

In order to ensure that old Python-2-only scripts break cleanly and promptly in a Python-3-only system environment, please make sure to reserve the command name `python` and the `#!` path `/usr/bin/python` for Python 2.

That means, in any context (other than a virtualenv) where Python 3 is installed and Python 2 isn’t, only `/usr/bin/python3` and `python3` should be available. `/usr/bin/python` must not exist at all, and the bare command name `python` must not work.

This applies to _all_ build environments, whether or not they are technically Python-related, since it is a popular scripting language for other types of build.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [April 15, 2019, 11:44pm UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/2 "2019-04-15T23:44:45Z")

</div>

I don’t think this would apply. There will be no changes to the non-Python jobs; if it was working before, it would still work.

Only the python builds that don’t specify the Python version will see the behavior change, and that will be fixed by specifying 2.7.

---

<div class="post-metadata">

**Author:** ![cclauss](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cclauss/32/912_2.png) [@cclauss](https://travis-ci.community/u/cclauss)\
**Post date:** [April 16, 2019, 5:40pm UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/3 "2019-04-16T17:40:18Z")

</div>

@BanzaiMan is correct.

Without **language: python** , the command **python --version** will output:  
**Python 2.7.6** on Travis CI Trusty and **Python 2.7.12** on Travis CI Xenial.

---

<div class="post-metadata">

**Author:** ![zackw](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/zackw/32/1594_2.png) [@zackw](https://travis-ci.community/u/zackw)\
**Post date:** [April 16, 2019, 6:00pm UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/4 "2019-04-16T18:00:57Z")

</div>

> [@BanzaiMan](#):
>
> Only the python builds that don’t specify the Python version will see the behavior change, and that will be fixed by specifying 2.7.

That’s still a dangerous and ill-advised change. `python` should never invoke Python 3, no matter what the context is. If I were BDFL I wouldn’t even allow it in a virtualenv.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [April 16, 2019, 9:55pm UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/5 "2019-04-16T21:55:42Z")

</div>

> [@zackw](#):
>
> `python` should never invoke Python 3

Then the python core team should make that decision, in my opinion.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [April 17, 2019, 1:20am UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/6 "2019-04-17T01:20:24Z")

</div>

FYI, in python-dev, [an update to PEP 394 is under discussion](https://mail.python.org/pipermail/python-dev/2019-April/157067.html) (and goes smoothly so far) that would

- recommend to use `python3` as the default Python command due to the upcoming drop of Py2
- let distributions choose what `python` means, effectively making it a “transitional” option with no guarantee for compatibility across distributions.
  - except in virtualenvs where it refers to the env’s interpreter.

---

<div class="post-metadata">

**Author:** ![zackw](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/zackw/32/1594_2.png) [@zackw](https://travis-ci.community/u/zackw)\
**Post date:** [April 17, 2019, 11:29am UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/7 "2019-04-17T11:29:52Z")

</div>

> [@native-api](#):
>
> FYI, in python-dev, [an update to PEP 394 is under discussion](https://mail.python.org/pipermail/python-dev/2019-April/157067.html)

I’m aware. I think the “let distributions choose what `python` means” part is a serious error and I mean to bring that up with them. Meanwhile, for itself, Travis can and should commit to the absence of the `python` command in its build environments when Python 2 is not available.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [April 17, 2019, 12:09pm UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/8 "2019-04-17T12:09:48Z")

</div>

> [@zackw](#):
>
> I think the “let distributions choose what `python` means” part is a serious error and I mean to bring that up with them.

Before you do that, reread my previous post after the edits. This provision is meant to help distributions gradually move `python` from Py2 to Py3 with minimal pain. So it is provisional, progressive, and I’m pretty positive that it will land.

---

<div class="post-metadata">

**Author:** ![webknjaz](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/webknjaz/32/34_2.png) [@webknjaz](https://travis-ci.community/u/webknjaz)\
**Post date:** [April 17, 2019, 3:46pm UTC](https://travis-ci.community/t/the-python-command-should-be-permanently-reserved-for-python-2/3031/9 "2019-04-17T15:46:53Z")

</div>

Please also take into account that RPM-based distros chose to not have `python` at all by default having two separate `python2` and `python3` which is IMHO the best decision possible. But I don’t think that Travis CI should maintain modified OS images anyway.
