brew install python or brew info python output mentions:
Unversioned symlinks
python,python-config,pipetc. pointing topython3,python3-config,pip3etc., respectively, have been installed into /opt/homebrew/opt/[email protected]/libexec/bin
So running, as root (for Bash (executable bash), use the ~/.bash_profile file):
echo 'export PATH=/opt/homebrew/opt/[email protected]/libexec/bin:$PATH' >> ~/.zprofile
source ~/.zprofile
gets you those symlinks created by Homebrew, python=python3, pip=pip3, etc.
python --version
Output:
Python 3.9.10
And:
pip --version
Output:
pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
Answer from Callum M on Stack OverflowPython: command not found
Homebrew-installed Python libraries not recognised by VS Code (Mac OS)
How do I use Homebrew installed Python as the default Python? - Stack Overflow
terminal - Running `pip` gives 'command not found' after successful Python homebrew install - Stack Overflow
brew install python or brew info python output mentions:
Unversioned symlinks
python,python-config,pipetc. pointing topython3,python3-config,pip3etc., respectively, have been installed into /opt/homebrew/opt/[email protected]/libexec/bin
So running, as root (for Bash (executable bash), use the ~/.bash_profile file):
echo 'export PATH=/opt/homebrew/opt/[email protected]/libexec/bin:$PATH' >> ~/.zprofile
source ~/.zprofile
gets you those symlinks created by Homebrew, python=python3, pip=pip3, etc.
python --version
Output:
Python 3.9.10
And:
pip --version
Output:
pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
If you want to install Python 3 using Homebrew:
brew install python3
Output:
==> Downloading http://python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2
Already downloaded: /Library/Caches/Homebrew/python3-3.3.0.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/python3/3.3.0 --enable-ipv6 --datarootdir=/usr/local/Cell
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python3/3.3.0
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python3/3.3.0/share/python3
==> Downloading https://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
Already downloaded: /Library/Caches/Homebrew/distribute-0.6.35.tar.gz
==> /usr/local/Cellar/python3/3.3.0/bin/python3.3 -s setup.py install --force --verbose --install-li
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/pip-1.3.1.tar.gz
==> /usr/local/Cellar/python3/3.3.0/bin/python3.3 -s setup.py install --force --verbose --install-li
==> Caveats
Homebrew's Python3 framework
/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework
Distribute and Pip have been installed. To update them
pip3 install --upgrade distribute
pip3 install --upgrade pip
To symlink "Idle 3" and the "Python Launcher 3" to ~/Applications
`brew linkapps`
You can install Python packages with
`pip3 install <your_favorite_package>`
They will install into the site-package directory
/usr/local/lib/python3.3/site-packages
Executable python scripts will be put in:
/usr/local/share/python3
so you may want to put "/usr/local/share/python3" in your PATH, too.
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
Once installed update your system PATH variable, add the next line to the ~/.bash_profile file:
export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH
And then:
source ~/.bash_profile
Now launch Python:
python3
Output:
Python 3.3.0 (default, Mar 26 2013, 10:01:40)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
You can check the python3 path:
which python3
Output:
/usr/local/bin/python3
Hi all!
I've been wanting to experiment with the wonderful Manim library, but I am running into some problems. As per the installation guide, I've used Homebrew to install Manim. I've also used Homebrew to install the latest Python 3.12. Anyway, Python and Manim both work fine! However, VS Code does not recognise the Manim syntax, and that's what I want to fix.
From what I've read online, the problem seems to be that my VS Code - which I also installed with Homebrew - is not using the right Python interpreter. The fix is supposed to be selecting the right Python interpreter. However, I have no idea which one that is. The only 3.12 interpreter that VS Code recommends is in /opt/homebrew/bin/python3. There is the option of entering an interpreter path, but how do I know which that will be?
Any tips would be super helpful! As you can probably tell, this whole Homebrew stuff is quite new to me, so I would really appreciate some hand holding here.
P.S. I don't know if it matters, but although the Manim installation guide says to install Manim with pip, this did not work on my machine, which uses Apple M3. I replaced the pip install command with the Brew one, and that worked.
As suggested by the Homebrew (executable brew) installer itself, be sure to add this to your .bashrc file or .zshrc file:
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
For Apple silicon machines, the paths are slightly different. After running brew install python, you must ensure your ~/.zshrc file uses the correct Homebrew paths:
# Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
# Homebrew: Python
export PATH="/opt/homebrew/opt/python/libexec/bin:$PATH"
Results:
% which python
/opt/homebrew/opt/python/libexec/bin/python
% python --version
Python 3.9.9
% which pip
/opt/homebrew/opt/python/libexec/bin/pip
% pip -V
pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
Brew's Python interpreter changed its location again and I had to update my ~/.zshrc file to:
export PATH="$(brew --prefix)/opt/python@3/libexec/bin:$PATH"
There isn't a .../opt/python/... anymore which is annoying, because now I have to specify v3 explicitly, but at least better than having to specify the minor version like in the comments.
I ran into this problem myself on OS X. In my case, I finally did a listing of /usr/local/bin, and found that I had links from pip2, pip2.7, pip3, and pip3.6. What I lacked was a link from just pip. I don't know if this is just part of a new standard, or if I was missing something that would select one of the two, or if having both Python 2 and Python 3 installed meant that I didn't get a simple pip command. Either way, running brew doctor didn't reveal or solve any issues.
In this case, just running pip3 or pip2 (instead of pip) seemed to do the trick for me. In my case, I ran pip3 and everything installed and ran as expected.
My Background
I had this same problem, and I think it may have arisen after upgrading to OSX 10.11 (El Capitan). When trying to run pip, I got -bash: pip: command not found I also tried python -m pip which did not work either (no module found). Trying to unlink and relink python through Homebrew did not work.
The Fix
I was able to fix the problem by completely uninstalling and reinstalling python via Homebrew.
brew uninstall python && brew install python
If you want to remove older versions of python too, use
brew uninstall --force python && brew install python
None of my existing pip installs were affected, and are all still listed when I run pip freeze. After the reinstall, the binary is now symlinked to /usr/local/bin/pip, which did not exist before. Strangely, the actual binary in /usr/local/Cellar/python/2.7.11/bin/pip did not exist before the reinstall either.
I’ve been trying to use pip for a while now and was unable to because my Mac kept using the pre installed python 2 not python 3 which I installed. It was recommended that I use homebrew so I downloaded it and then got an error. As I said in the title I tried something I saw and now when I enter “python —version” or “pip —version” I get a ZHS command not found error. Can anyone help me? I’ve been trying for about a week now just to be able to run python files on my Mac. Thanks in advance for the help
Did you already installed your python 3 version with:
brew install python3 && cp /usr/local/bin/python3 /usr/local/bin/python
If you're not familiar with brew, check the documentation: https://docs.brew.sh/Installation
In the next step I don't really get your problem properly. You can start any file with python3 <src_to_file/file.py> or just use a source-code editor like VS-Code.
I always install python directly from python.org. The installer comes with the Launcher.app, and the IDLE developer environment.
I wish mac had an uninstall utility like windows that showed all programs on windows regardless of how they were installed.
Today I wanted to upgrade python, which for some reason automatically works even though I don't remember ever installing it. Maybe VSCode installed it itself? No idea. In any case I saw that it was an older version so I tried upgrading, I couldn't find a command from within Python to upgrade itself so I tried brew, but brew can't find python (or python3) so I looked for it in the apps. Not there.
I tried using the GUI installer hoping it'd find its own previous version like what happens in windows, and offer to upgrade.
Also I'm not sure where "python" has disappeared now, it seems to have cleared the path and replaced it with a python3 so on the terminal doing "python --version" no longer outputs 3.9.x but instead says not found, while a python3 --version command now works and outputs 3.12.