简体   繁体   中英

Mac Not Finding Homebrew Installed Python

So I've installed python via homebrow. When I do brew info python I get this:

python: stable 3.6.5 (bottled), devel 3.7.0rc1, HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.6.5_1 (5,107 files, 103.0MB) *
  Poured from bottle on 2018-06-18 at 10:15:49
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✔, sphinx-doc ✘
Required: gdbm ✔, openssl ✔, readline ✔, sqlite ✔, xz ✔
Optional: tcl-tk ✘
==> Options
--with-tcl-tk
    Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
--devel
    Install development version 3.7.0rc1
--HEAD
    Install HEAD version
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

Pip, setuptools, and wheel have been installed. To update them run
  pip3 install --upgrade pip setuptools wheel

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.6/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

I'm ultimately trying to do pip3 install numpy but when I do that, I get this message:

-bash: pip3: command not found

pip install numpy seems to point to the Apple default 2.7 python version:

Requirement already satisfied: numpy in /Library/Python/2.7/site-packages (1.14.5)

So the problem seems to be in my .bash_profile as which python gives /usr/bin/python .

Here's what that looks like:

export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/Cellar/python/3.6.5_1/bin:$PATH

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

export PATH=$PATH:/Users/thammond/Library/Android/sdk/platform-tools

###########
export PATH=/usr/local/Cellar/postgresql\@9.6/9.6.6/bin:$PATH

###########

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

I confirmed that /usr/local/ was listed at the top and also tried adding in export PATH=/usr/local/Cellar/python/3.6.5_1/bin:$PATH

But it's still finding the wrong python. Any ideas where I'm going wrong?

EDIT:

When I run python3 -m ensurepip --upgrade I see this:

Requirement already up-to-date: setuptools in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already up-to-date: pip in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages

When I run python3 -m ensurepip -vvv -U I get this:

Ignoring indexes: https://pypi.python.org/simple
0 location(s) to search for versions of setuptools:
Skipping link /var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2 (from -f); not a file
Skipping link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl; wrong project name (not setuptools)
Found link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl, version: 39.0.1
Local files found: /private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl
Installed version (39.2.0) is most up-to-date (past versions: 39.0.1)
Requirement already up-to-date: setuptools in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
0 location(s) to search for versions of pip:
Found link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl, version: 9.0.3
Skipping link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl; wrong project name (not pip)
Local files found: /private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl
Installed version (10.0.1) is most up-to-date (past versions: 9.0.3)
Requirement already up-to-date: pip in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Cleaning up...

When I look in /usr/local/Cellar/python/3.6.5_1/bin/ with finder I don't see a pip/pip3 file.

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'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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM