繁体   English   中英

Mac没有找到Homebrew安装的Python

[英]Mac Not Finding Homebrew Installed Python

所以我通过homebrow安装了python。 当我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

我最终试图做pip3 install numpy但是当我这样做时,我收到这条消息:

-bash: pip3: command not found

pip install numpy似乎指向Apple默认的2.7 python版本:

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

所以问题似乎出现在我的.bash_profilewhich python给出了/usr/bin/python

这是看起来像:

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*

我确认/usr/local/列在顶部,并尝试添加export PATH=/usr/local/Cellar/python/3.6.5_1/bin:$PATH

但它仍然发现错误的python。 我出错的任何想法?

编辑:

当我运行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

当我运行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...

当我使用finder查看/usr/local/Cellar/python/3.6.5_1/bin/ ,我没有看到pip / pip3文件。

您是否尝试调用/usr/local/Cellar/python3/3.6.5_1/bin/pip3 如果它工作,这意味着pip安装已成功完成,你的bashfile将是错误的。 但是,bashfile对我来说看起来很正常。


你确认/usr/local/Cellar/python3/3.6.5_1/bin/中有pip3吗? 如果它不存在,则首先不安装pip

这个页面似乎有同样的问题(“pip3没有安装python 3.4.2#33897”)
“pip3没有安装python 3.4.2#33897”的提问者通过删除/private/var/folders/hy/l_6wd1ps0nz835v4g41zhhtr0000gn/T/pip_build
可能是因为Brew未能完成pip安装。

首先,要引导pip安装程序,请点击python3 -m ensurepip --upgradepython -m ensurepip 如果它不起作用,尝试点击python3 -m ensurepip -vvv -U并告诉它说什么。

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

brew uninstall python3
brew install python3

现在我可以运行pip3 install numpy --user

暂无
暂无

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

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