Skip to content

Commit a0e33fd

Browse files
authored
(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.
1 parent a679d6f commit a0e33fd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/starting/install3/osx.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ will launch the homebrew-installed Python 3 interpreter.
102102
If the Homebrew version of Python 2 is installed then ``pip2`` will point to Python 2.
103103
If the Homebrew version of Python 3 is installed then ``pip3`` will point to Python 3.
104104

105+
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.
106+
107+
.. code-block:: console
108+
109+
# Do I have a Python 2 problem?
110+
$ python --version
111+
Python 2.7.10 # Referencing OSX system install
112+
$ which python
113+
/usr/bin/python # Yup, homebrew's would be in /usr/local/bin
114+
115+
# Symlink /usr/local/bin/python to python3
116+
$ ln -s /usr/local/bin/python3 /usr/local/bin/python
117+
118+
$ python --version
119+
Python 3.6.4 # Success!
120+
# If you still see 2.7 ensure in PATH /usr/local/bin/ takes pecedence over /usr/bin/
105121
106122
Pipenv & Virtual Environments
107123
-----------------------------

0 commit comments

Comments
 (0)