2

Typing Python on my Terminal shows

Python 3.9.5 (default, May 4 2021, 03:36:27) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin Type "help", "copyright", "credits" or "license" for more information. 

When in fact I have installed the latest version, 3.10.6, which shows when I type python3 --version. Typing just python --version returns 3.9.5 again. It seems that the default version is 3.9.5 and not updated, or am I wrong? Either way, how do I solve this? I've tried both downloading and installing it directly, as well as through brew install ..., both giving successful installs, but not updating the default version (3.9.5 -> 3.10.6)

15
  • Uninstall all versions and reinstall? Commented Aug 15, 2022 at 16:20
  • 1
    Having multiple Python versions on your computer is always a headache... Try which python and which python3 to see where their executables are respectively, that might help you troubleshoot. Commented Aug 15, 2022 at 16:23
  • 2
    Notice that which is hardly ever the right tool (unless one is using tcsh). The person asking, judging by their use of Homebrew and Terminal, seems to be on a Mac, which, on modern versions of macOS, means the default shell is zsh, where whence -v is more appropriate. Commented Aug 15, 2022 at 16:30
  • @lancylot2004 which python gave me /usr/local/opt/[email protected]/libexec/bin/python while which python3gave /opt/homebrew/bin/python3 ... I'm not good at using the terminal at all, I just code and that's it, so I'm kind of clueless as to how to solve this Commented Aug 15, 2022 at 16:32
  • @TurePålsson I used whence -v python and got in return the same as when using which python but with "python is" added in the beginning. Also typed whence -v python and it again returned another path Commented Aug 15, 2022 at 16:35

2 Answers 2

0

The solution, as provided in the comments, was to create a ~/.zshrc file (How to create a ~/.zshrc file) and then to replace the existing path with export PATH="$(brew --prefix [email protected])/libexec/bin:$PATH"

Sign up to request clarification or add additional context in comments.

Comments

-1

Your issue is that python is still pointing to Python 3.9.5 while python3 refers to Python 3.10.6:

  1. Check which version is being used
which python which python3 ls -l $(which python) 
  1. Add this to ~/.zshrc (or ~/.bashrc if using Bash):
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH" 

Then Run:

source ~/.zshrc 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.