1

I have a working python version - python3 --version gave Python 3.9.6. Then I used homebrew to install python 3.12. It is located in /opt/homebrew/bin according to the homebrew installer. If I run whereis python I get usr/bin/python3and /opt/homebrew/share/man/man1/python3.1 instead. Should I just delete the python binary in /usr/bin/Pythonor is there a better way? In the cloned git repo I will be working with I need to install a virtual environment with venv. Can there be any conflicts if I use the python version in the homebrew directory and delete the binary in /usr/bin?

echo $PATH is /Applications/Sublime Text.app/Contents/SharedSupport/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/david/.cargo/bin

6
  • So I just added /opt/homebrew/share/man/man1/python3.1 to $PATH and it works. Sorry for asking here. Commented May 3 at 14:59
  • You are welcome to ask, that's what this site is all about.
    – nohillside
    Commented May 3 at 15:20
  • 1
    Having said that: Having python in /opt/homebrew/share/man/man1 is highly unusual, you shouldn't even have to add this to your path (it only contains manual pages, not binaries). What is the output of ls -l /opt/homebrew/bin/python3{,.12}?
    – nohillside
    Commented May 3 at 15:22
  • /opt/homebrew/share/man should be in MANPATH. Sounds like the brew installation isn't complete. Your brew installation would have instructed you to add eval "$(/opt/homebrew/bin/brew shellenv)" to ~/.zprofile. This sets up the correct paths at the beginning of a shell session. Commented May 3 at 15:41
  • @AndyGriffiths See OPs comment above, PATH looks ok.
    – nohillside
    Commented May 3 at 16:08

2 Answers 2

1

You can't delete Apple's /usr/bin/python3.

Either make sure that your homebrew version comes first in $PATH; or make sure you specify the full path you want; or use a virtual environment.

0

The better way is to use pyenv. It will manage multiple Python versions, the Apple provided version, Homebrew installed versions, and many versions that pyenv provides in its install functionality (Anaconda etc).

In addition you can create virtual environments, including in IDEs such as VSCode & Pycharm, the preferred way to manage per-project dependencies and versions.

pyenv can be installed from Homebrew, instructions are on the above linked Github page.

You must log in to answer this question.

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