3

I installed python3 with homebrew and can access it with python3 command in terminal.

I'm installing a command line app that needs python3. When I try to use it it says:

Python 3.3+ required

When I do python --version it reports python 2.7.

How can I get the app to use python3?

2
  • 1
    you should use python3 --version to check.
    – aircraft
    Jul 1, 2017 at 3:45
  • Does Homebrew install python in a framework?
    – fd0
    Jul 1, 2017 at 5:02

3 Answers 3

-1

If there is no other application to use the python2.7, you can use alias python to python3:

In the ~/.bashrc:

add the alias python=python3

1
  • Yes I know. I'm asking how to get the app to use python3.
    – Harry
    Jul 1, 2017 at 4:33
0

OK, so if you already have python 3.3 or more, then:

  1. Open the script in an text editor(TextEdit, vim, etc.)
  2. Replace all python with python3
  3. Save and exit

... or just do like @aircraft said, alias it if nothing else uses py2.

0

I do it this way although I don't get consistent results with these commands on different Macs. Your milage may vary:

1. install homebrew if you dont have it
2. brew install zlib
3. brew install python (to get system level python3; this step is optional)
4. brew install pyenv
5. pyenv install 3.7.0  (to get shimmed python3)
6. pyenv versions
7. pyenv global 3.7.0
8. python --version  (should say 3.7.0)

Secondly, I might add this to my bash profile:

# put in .bash_profile
export PATH=".:/usr/local/bin:/usr/local:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/sw/bin:$PATH"
export PATH="$PATH:/usr/local/git/bin"
export PATH="$PATH:$HOME/.pyenv/shims" # add Python version manager 'brew install pyenv'
eval "$(pyenv init -)"
echo "Python shimmed: " + $(pyenv which python)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .