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'm not really sure why it worked this time but just for kicks I decided to uninstall and reinstall python from homebrew again but this time it worked and pip3 installed correctly and works.
brew uninstall python3
brew install python3
now I can run pip3 install numpy --user
Did you try to invoke /usr/local/Cellar/python3/3.6.5_1/bin/pip3 ? If it works, it means pip installation has been successfuly completed and your bashfile will be wrong. However, the bashfile looks normal for me.
Did you confirm that there is pip3 in /usr/local/Cellar/python3/3.6.5_1/bin/?
If it does not exist, pip is not installed in the first place.
It seems to have the same problem with this page ("pip3 not installed with python 3.4.2 #33897").
The questioner of "pip3 not installed with python 3.4.2 #33897" have finaly solved it by removing /private/var/folders/hy/l_6wd1ps0nz835v4g41zhhtr0000gn/T/pip_build.
It may be because of Brew had failed to complete pip installation.
First, to bootstrap the pip installer, hit python3 -m ensurepip --upgrade and python -m ensurepip.
If it won't work, try to hit python3 -m ensurepip -vvv -U and tell what do it say.
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
The error message says you don’t have permission to write under /usr/local/lib/python2.7/site-packages/pkg_resources.
The following steps should work:
Remove your broken Python install:
brew uninstall pythonEnsure you own that directory:
sudo chown -R $(whoami):admin /usr/local/lib/python2.7/site-packagesRetry:
brew install python
Install Python3 with Brew Enter brew command into terminal
brew install python3
Optional, PATH environment Set up PATH environment variable, if you used HomeBrew to install Python3, then HomeBrew already added PATH.
Do not change PATH environment if you can launch python3 from terminal.
Add the following line to your ~/.profile file
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Usually your Python installation directory looks like this, add it to your PATH
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"