gpt4 book ai didi

python - Mac 找不到 Homebrew 安装的 Python

转载 作者:太空宇宙 更新时间:2023-11-03 11:16:22 36 4
gpt4 key购买 nike

所以我通过 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_profile 中,因为 which 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:$路径

但它仍然在寻找错误的 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

似乎和this page ("pip3 not installed with python 3.4.2 #33897")有同样的问题.
"pip3 not installed with python 3.4.2 #33897"的提问者最终通过删除 /private/var/folders/hy/l_6wd1ps0nz835v41zhhtr0000gn/T/pip_build 解决了这个问题。
可能是因为 Brew 未能完成 pip 安装。

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

关于python - Mac 找不到 Homebrew 安装的 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50913484/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com