简体   繁体   English

Mac没有找到Homebrew安装的Python

[英]Mac Not Finding Homebrew Installed Python

So I've installed python via homebrow. 所以我通过homebrow安装了python。 When I do brew info python I get this: 当我brew info python我得到这个:

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: 我最终试图做pip3 install numpy但是当我这样做时,我收到这条消息:

-bash: pip3: command not found

pip install numpy seems to point to the Apple default 2.7 python version: pip install numpy似乎指向Apple默认的2.7 python版本:

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 . 所以问题似乎出现在我的.bash_profilewhich python给出了/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 我确认/usr/local/列在顶部,并尝试添加export PATH=/usr/local/Cellar/python/3.6.5_1/bin:$PATH

But it's still finding the wrong python. 但它仍然发现错误的python。 Any ideas where I'm going wrong? 我出错的任何想法?

EDIT: 编辑:

When I run python3 -m ensurepip --upgrade I see this: 当我运行python3 -m ensurepip --upgrade我看到了这个:

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: 当我运行python3 -m ensurepip -vvv -U我得到这个:

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. 当我使用finder查看/usr/local/Cellar/python/3.6.5_1/bin/ ,我没有看到pip / pip3文件。

Did you try to invoke /usr/local/Cellar/python3/3.6.5_1/bin/pip3 ? 您是否尝试调用/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. 如果它工作,这意味着pip安装已成功完成,你的bashfile将是错误的。 However, the bashfile looks normal for me. 但是,bashfile对我来说看起来很正常。


Did you confirm that there is pip3 in /usr/local/Cellar/python3/3.6.5_1/bin/ ? 你确认/usr/local/Cellar/python3/3.6.5_1/bin/中有pip3吗? If it does not exist, pip is not installed in the first place. 如果它不存在,则首先不安装pip

It seems to have the same problem with this page ("pip3 not installed with python 3.4.2 #33897") . 这个页面似乎有同样的问题(“pip3没有安装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 . “pip3没有安装python 3.4.2#33897”的提问者通过删除/private/var/folders/hy/l_6wd1ps0nz835v4g41zhhtr0000gn/T/pip_build
It may be because of Brew had failed to complete pip installation. 可能是因为Brew未能完成pip安装。

First, to bootstrap the pip installer, hit python3 -m ensurepip --upgrade and python -m ensurepip . 首先,要引导pip安装程序,请点击python3 -m ensurepip --upgradepython -m ensurepip If it won't work, try to hit python3 -m ensurepip -vvv -U and tell what do it say. 如果它不起作用,尝试点击python3 -m ensurepip -vvv -U并告诉它说什么。

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. 我不确定为什么它这次工作,但只是为了踢我决定卸载并重新安装从自制程序的python但这次它工作和pip3正确安装和工作。

brew uninstall python3
brew install python3

now I can run pip3 install numpy --user 现在我可以运行pip3 install numpy --user

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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