(osx) how to make python reference python3

I noticed that the very next page (which is no longer OSX specific) makes the assumption that `python` will invoke the Python 3 interpreter, while the last mention of versions on this page leaves `python` referencing the OSX System Python interpreter.

I honestly do not know if this is the "correct" way to configure this default. It looks like brew is cautious about symlinking over the native Python 2.7.10 (High Sierra) and they might have good reason. All of my projects are Python 3 now, so i'm ready to "make it ~facebook~ PATH official with Python 3"

Regardless of how it's done - or if it's a bad idea - it's worth mentioning IMO because there is a discontinuity of where this page leaves `python` and where the next page assumes `python` to be.
This commit is contained in:
Ken Colton
2018-01-31 22:22:28 -05:00
committed by GitHub
parent a679d6f228
commit a0e33fd384
+16
View File
@@ -102,6 +102,22 @@ will launch the homebrew-installed Python 3 interpreter.
If the Homebrew version of Python 2 is installed then ``pip2`` will point to Python 2.
If the Homebrew version of Python 3 is installed then ``pip3`` will point to Python 3.
The rest of the guide will assume that ``python`` references Python 3. You can simply choose to always invoke ``python3`` instead, and much is backwards compatible. However, performing the following steps will set Python 3 as the default interpreter for ``python`` in a shell.
.. code-block:: console
# Do I have a Python 2 problem?
$ python --version
Python 2.7.10 # Referencing OSX system install
$ which python
/usr/bin/python # Yup, homebrew's would be in /usr/local/bin
# Symlink /usr/local/bin/python to python3
$ ln -s /usr/local/bin/python3 /usr/local/bin/python
$ python --version
Python 3.6.4 # Success!
# If you still see 2.7 ensure in PATH /usr/local/bin/ takes pecedence over /usr/bin/
Pipenv & Virtual Environments
-----------------------------