Skip to content

Commit a904091

Browse files
authored
Merge pull request realpython#872 from kcolton/patch-1
(osx) how to make `python` reference `python3`
2 parents a679d6f + a0e33fd commit a904091

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)