-1

I tried to install python 3 using home-brew. It tells me that it's already installed.

Whenever I run a python test.py it uses python2. How can I change the default to python 3?

kanayt
  • 157
  • 1
  • 3
  • 10

1 Answers1

0

If Python shows up under the command, it's installed. What version is it? Let's check:

$ brew info python
python: stable 3.7.3 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.2_1 (8,437 files, 118MB) *
## further output not included ##

The Homebrew maintainers have updated the default Python bottle to point to the latest release. Since the Homebrew maintainers are more dependable at updating the release than most of us, you can use Homebrew's version of Python 3 with the following command:

$ brew update && brew upgrade python

Now you must point the alias to the copy of Python that Homebrew manages:

# If you added the previous alias, use a text editor to update the line to the following.
alias python=/usr/local/bin/python3

To make sure the path above points to where Homebrew installed Python in your environment, you can run brew info python and look for the path information.

Esme Povirk
  • 3,004
  • 16
  • 24
L00P
  • 16