Home > OS >  installed python 3.10 but not recognised in terminal (mac OS monterey)
installed python 3.10 but not recognised in terminal (mac OS monterey)

Time:08-05

I have used both the python installer and brew to try to install python 3.10 but version 3.9.12 shows up in terminal, even though python 3.10 can be seen in finder.

screenshot showing the issue

CodePudding user response:

Since you're on macos Monterey, you have to set your PATH for your shell (zsh unless you've made a default shell change):

  1. For using Python 3.10 from the Installer

    If you got Python 3.10 from the python.org installer, put a line like this in your ~/.zshrc file:

    # somewhere in your ~/.zshrc, probably near the bottom
    export PATH="/Library/Frameworks/Python.framework/Versions/3.10/bin:${PATH}"
    
  2. For Python 3.10 from homebrew

    Similar to above, but a different path

    # assuming you did "brew install [email protected]"
    # in your ~/.zshrc, near the bottom
    export PATH="$(brew --prefix [email protected])/bin:$PATH"
    

Regardless of which option you pick, open up a new terminal instance or run exec zsh in an existing terminal and you should hopefully have the right python3 version running.

# In my own .zshrc, I did this...
# export PATH="$(brew --prefix [email protected])/bin:$PATH"

> exec zsh
> python3 -V
Python 3.10.5

CodePudding user response:

On windows the version of python can be specified by tacking on -versionNumber to your python terminal call

python -3.1

  • Related