最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Mac中用brew查看之前已安装过的Python3的信息

Mac crifan 3726浏览 0评论

折腾:

【已解决】Mac本地用pipenv搭建Flask开发环境

去尝试用brew去查看之前安装的Python3的包括版本,安装位置等信息

brew check installed

List of all packages installed using Homebrew – Ask Different

<code>➜  robotDemo brew list
carthage    gdbm        lrzsz        openssl        python        sqlite        watchman    xvid
ffmpeg        icu4c        mongodb        pcre        python3        sshpass        wget        xz
flow        lame        node        pkg-config    readline    telnet        x264
</code>

有python3的,再去看看python3的版本:

没有找到python3或py3:

想要查看brew安装的python3的版本:

参考:

bash – Detect if homebrew package is installed – Stack Overflow

<code>➜  robotDemo brew ls --version python3
/usr/local/Cellar/python/2.7.13/bin/2to3
/usr/local/Cellar/python/2.7.13/bin/2to3-2
/usr/local/Cellar/python/2.7.13/bin/2to3-2.7
/usr/local/Cellar/python/2.7.13/bin/easy_install
/usr/local/Cellar/python/2.7.13/bin/easy_install-2.7
/usr/local/Cellar/python/2.7.13/bin/idle
/usr/local/Cellar/python/2.7.13/bin/idle2
/usr/local/Cellar/python/2.7.13/bin/idle2.7
/usr/local/Cellar/python/2.7.13/bin/pip
/usr/local/Cellar/python/2.7.13/bin/pip2
/usr/local/Cellar/python/2.7.13/bin/pip2.7
/usr/local/Cellar/python/2.7.13/bin/pydoc
/usr/local/Cellar/python/2.7.13/bin/pydoc2
/usr/local/Cellar/python/2.7.13/bin/pydoc2.7
/usr/local/Cellar/python/2.7.13/bin/python
/usr/local/Cellar/python/2.7.13/bin/python-config
/usr/local/Cellar/python/2.7.13/bin/python2
/usr/local/Cellar/python/2.7.13/bin/python2-config
/usr/local/Cellar/python/2.7.13/bin/python2.7
/usr/local/Cellar/python/2.7.13/bin/python2.7-config
/usr/local/Cellar/python/2.7.13/bin/pythonw
/usr/local/Cellar/python/2.7.13/bin/pythonw2
/usr/local/Cellar/python/2.7.13/bin/pythonw2.7
/usr/local/Cellar/python/2.7.13/bin/smtpd.py
/usr/local/Cellar/python/2.7.13/bin/smtpd2.7.py
/usr/local/Cellar/python/2.7.13/bin/smtpd2.py
/usr/local/Cellar/python/2.7.13/bin/wheel
/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/ (5055 files)
/usr/local/Cellar/python/2.7.13/IDLE.app/Contents/ (8 files)
/usr/local/Cellar/python/2.7.13/lib/pkgconfig/ (3 files)
/usr/local/Cellar/python/2.7.13/libexec/pip/ (540 files)
/usr/local/Cellar/python/2.7.13/libexec/setuptools/ (272 files)
/usr/local/Cellar/python/2.7.13/libexec/wheel/ (93 files)
/usr/local/Cellar/python/2.7.13/Python Launcher.app/Contents/ (17 files)
/usr/local/Cellar/python/2.7.13/share/man/ (3 files)
/usr/local/Cellar/python/2.7.13/share/python/ (315 files)
</code>

结果并没有输出我要的python3

Check package information installed by Homebrew – Pete Houston – Medium

然后找到了python3的信息:

<code>➜  robotDemo brew help
Example usage:
  brew search [TEXT|/REGEX/]
  brew (info|home|options) [FORMULA...]
  brew install FORMULA...
  brew update
  brew upgrade [FORMULA...]
  brew uninstall FORMULA...
  brew list [FORMULA...]

Troubleshooting:
  brew config
  brew doctor
  brew install -vd FORMULA

Developers:
  brew create [URL [--no-fetch]]
  brew edit [FORMULA...]
https://docs.brew.sh/Formula-Cookbook

Further help:
  man brew
  brew help [COMMAND]
  brew home
➜  robotDemo brew info python3
python: stable 3.6.4 (bottled), devel 3.7.0b2, HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/2.7.13 (6,337 files, 86.7MB) *
  Built from source on 2017-05-06 at 15:09:57
/usr/local/Cellar/python/3.6.1 (7,961 files, 110.0MB)
  Built from source on 2017-05-06 at 14:34:30
From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/python.rb
==&gt; Dependencies
Build: pkg-config ✔, sphinx-doc ✘
Required: gdbm ✘, openssl ✔, readline ✔, sqlite ✘, xz ✔
Optional: tcl-tk ✘
==&gt; Options
--with-tcl-tk
    Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
--devel
    Install development version 3.7.0b2
--HEAD
    Install HEAD version
==&gt; 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 &lt;package&gt;
They will install into the site-package directory
  /usr/local/lib/python3.6/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
➜  robotDemo brew search python3
==&gt; Searching local taps...
python3 ✔                                                                          boost-python3
==&gt; Searching taps on GitHub...
==&gt; Searching blacklisted, migrated and deleted formulae...
</code>

但是并不存在此文件:

<code>➜  robotDemo ll /usr/local/bin/python3
ls: /usr/local/bin/python3: No such file or directory
➜  robotDemo ll /usr/local/bin/py
pydoc@             pydoc2.7@          pylint*            python@            python2@           python2.7@         pythonw@           pythonw2.7@
pydoc2@            pyhtmlizer*        pyreverse*         python-config@     python2-config@    python2.7-config@  pythonw2@
</code>

brew bin python3  No such file or directory

Brew removed /usr/local/bin/python3 · Issue #24880 · Homebrew/homebrew-core

先去:

<code>brew upgrade
</code>

后再去:

<code>➜  robotDemo brew list --versions
carthage 0.29.0 0.25.0
ffmpeg 3.3.4 3.4.2
flow 0.20.1 0.68.0
gdbm 1.13 1.14.1_1
gettext 0.19.8.1
icu4c 58.2 60.2
lame 3.100 3.99.5
libidn2 2.0.4
libunistring 0.9.9
lrzsz 0.12.20
mongodb 3.6.3
node 7.7.1 7.5.0 9.9.0
openssl 1.0.2o 1.0.2h_1 1.0.2k
pcre 8.42 8.38 8.39
pkg-config 0.29.1 0.29.2
python 3.6.4_4 2.7.13 3.6.1
readline 7.0.3_1
sqlite 3.22.0 3.18.0
sshpass 1.06
telnet 54.50.1
watchman 4.7.0 4.9.0 4.1.0
wget 1.17.1 1.19.4_1
x264 r2795 r2854
xvid 1.3.4 1.3.5
xz 5.2.2 5.2.3
➜  robotDemo brew list --versions | grep python
python 3.6.4_4 2.7.13 3.6.1
</code>

可见,此处是安装了的Python3的,但是却找不到。

python3 failed to build on 10.8.2 · Issue #16602 · Homebrew/legacy-homebrew

macos – Unable to Run Python 3 After Homebrew Installation – Stack Overflow

python – How do I use the python3 version that is installed in Homebrew instead of the one that is installed in the Library? – Stack Overflow

然后直接去安装,提示我已经装过了:

<code>➜  robotDemo brew install python3
Warning: python 3.6.4_4 is already installed and up-to-date
To reinstall 3.6.4_4, run `brew reinstall python`
</code>

brew install python3 Warning python 3  is already installed

brew link python3出错 – CSDN博客

<code>➜  robotDemo brew link python3
Warning: Already linked: /usr/local/Cellar/python/3.6.4_4
To relink: brew unlink python &amp;&amp; brew link python
</code>

Mac 下安装Python3.5出现“python3-3.5.0 already instal… – 简书

<code>➜  robotDemo ll -lha /usr/local/Cellar/python/
total 0
drwxr-xr-x   5 crifan  admin   160B  4 17 10:52 .
drwxr-xr-x@ 28 crifan  admin   896B  4 17 10:53 ..
drwxr-xr-x  13 crifan  admin   416B  3 28 10:53 2.7.13
drwxr-xr-x  13 crifan  admin   416B  3 28 10:53 3.6.1
drwxr-xr-x  13 crifan  admin   416B  4 17 10:52 3.6.4_4
</code>

此处目录权限看起来没有问题。

不需要所谓的:

<code>sudo chown -R $(whoami):admin /usr/local
sudo chown $(whoami):admin /usr/local/Frameworks
</code>

无意间发现,此处python3又正常了:

<code>➜  robotDemo python3
Python 3.6.4 (default, Mar 22 2018, 13:54:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; quit()
➜  robotDemo which python3
/usr/local/bin/python3
➜  robotDemo ll /usr/local/bin/python3
lrwxr-xr-x  1 crifan  admin    36B  4 17 10:52 /usr/local/bin/python3 -&gt; ../Cellar/python/3.6.4_4/bin/python3
➜  robotDemo python3 --version
Python 3.6.4
</code>

不需要去解决,本身问题消失了,Python3可以正常使用了。

【总结】

之前用brew安装过了python3,现在去

which python3

却找不到,具体原因:

貌似是:brew过期了,或者是brew中的的python3的link被破坏了?

总之是:

<code>brew upgrade
</code>

后(又执行了一次,貌似不需要执行的:

<code>brew link python3
</code>

),就可以了。Python3就正常了。。。

此处是比较新的版本3.6.4:

<code>which python3
/usr/local/bin/python3

</code>

python3 –version

Python 3.6.4

转载请注明:在路上 » 【已解决】Mac中用brew查看之前已安装过的Python3的信息

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
91 queries in 0.220 seconds, using 22.18MB memory