環境構築についてです。シェルから「python3」が効かなくなってしまいました…。
ふだんなら python3 Pythonファイルのパス
を指定したら動くのに、 -bash: python3: command not found
と出ます。
きのううっかり brew upgrade
したのがきっかけのような気がします。
upgradeしたときのログを見ると、下記のように表示されています。
pyenv 1.2.4 -> 1.2.16 python 3.6.5 -> 3.7.6_1
python3
じゃなくて python
したら動くのかな? と思ったけどちがうようです…。
$ python -V Python 2.7.16
でした。Python2は使わないけど、OSに最初から入っていたので触らずに置いています。
brewでpython3のlistを見たところ下記の通りでした。
brew list python
でも同じ結果でした。
$ brew list python3 /usr/local/Cellar/python/3.6.5/bin/2to3 /usr/local/Cellar/python/3.6.5/bin/2to3-3.6 /usr/local/Cellar/python/3.6.5/bin/easy_install-3.6 /usr/local/Cellar/python/3.6.5/bin/idle3 /usr/local/Cellar/python/3.6.5/bin/idle3.6 /usr/local/Cellar/python/3.6.5/bin/pip3 /usr/local/Cellar/python/3.6.5/bin/pip3.6 /usr/local/Cellar/python/3.6.5/bin/pydoc3 /usr/local/Cellar/python/3.6.5/bin/pydoc3.6 /usr/local/Cellar/python/3.6.5/bin/python3 /usr/local/Cellar/python/3.6.5/bin/python3-config /usr/local/Cellar/python/3.6.5/bin/python3.6 /usr/local/Cellar/python/3.6.5/bin/python3.6-config /usr/local/Cellar/python/3.6.5/bin/python3.6m /usr/local/Cellar/python/3.6.5/bin/python3.6m-config /usr/local/Cellar/python/3.6.5/bin/pyvenv /usr/local/Cellar/python/3.6.5/bin/pyvenv-3.6 /usr/local/Cellar/python/3.6.5/bin/wheel3 /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/ (2787 files) /usr/local/Cellar/python/3.6.5/IDLE 3.app/Contents/ (8 files) /usr/local/Cellar/python/3.6.5/lib/pkgconfig/ (3 files) /usr/local/Cellar/python/3.6.5/libexec/bin/ (7 files) /usr/local/Cellar/python/3.6.5/libexec/pip/ (637 files) /usr/local/Cellar/python/3.6.5/libexec/setuptools/ (339 files) /usr/local/Cellar/python/3.6.5/libexec/wheel/ (49 files) /usr/local/Cellar/python/3.6.5/Python Launcher 3.app/Contents/ (16 files) /usr/local/Cellar/python/3.6.5/share/doc/ (1002 files) /usr/local/Cellar/python/3.6.5/share/man/ (2 files)
また、.bashrcは下記の通りでしたが、変えました。
PATH=$HOME/Users/hacosato/Library/Homebrew/bin:$PATH HOMEBREW_CACHE=$HOME/Users/hacosato/Library/Homebrew/cashe
自分自身の環境でどのようにPythonがインストールされているかもあまり理解できておらずなのですが…アドバイスいただけたらと思います。
macos 10.14.6
追記:
$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
$ brew config HOMEBREW_VERSION: 2.2.6 ORIGIN: https://github.com/Homebrew/brew HEAD: (16進数みたいなやつ) Last commit: 7 days ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: (16進数みたいなやつ) Core tap last commit: 28 minutes ago HOMEBREW_PREFIX: /usr/local CPU: 16-core 64-bit skylake Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby Clang: 11.0 build 1100 Git: 2.21.0 => /Applications/Xcode.app/Contents/Developer/usr/bin/git Curl: 7.54.0 => /usr/bin/curl macOS: 10.14.6-x86_64 CLT: N/A Xcode: 11.2.1 XQuartz: 2.7.11 => /opt/X11
$ brew info python3 python: stable 3.7.6 (bottled), HEAD Interpreted, interactive, object-oriented programming language https://www.python.org/ /usr/local/Cellar/python/3.6.4_2 (3,809 files, 58.4MB) Poured from bottle on 2018-01-07 at 22:11:55 /usr/local/Cellar/python/3.6.5 (4,872 files, 101.4MB) Poured from bottle on 2018-05-15 at 15:52:39 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb ==> Dependencies Build: pkg-config ✔ Required: gdbm ✔, openssl@1.1 ✔, readline ✔, sqlite ✔, xz ✔ ==> Options --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 You can install Python packages with pip3 install <package> They will install into the site-package directory /usr/local/lib/python3.7/site-packages See: https://docs.brew.sh/Homebrew-and-Python ==> Analytics install: 402,371 (30 days), 1,386,122 (90 days), 5,584,222 (365 days) install-on-request: 210,466 (30 days), 705,025 (90 days), 2,782,130 (365 days) build-error: 0 (30 days)
3.7と3.6が混ざってる…?
追記:
.bashrcは、変更して下記の通りです。
# PATH=$HOME/Library/Homebrew/bin:$PATH # HOMEBREW_CACHE=$HOME/Library/Homebrew/cashe export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
$ brew unlink python3 $ brew install python3
を実行しました。結果は下記の通りです。
$ brew unlink python3 ==> Tapping homebrew/core Cloning into '/Users/hacosato/Library/Homebrew/Library/Taps/homebrew/homebrew-core'... remote: Enumerating objects: 5140, done. remote: Counting objects: 100% (5140/5140), done. remote: Compressing objects: 100% (4939/4939), done. remote: Total 5140 (delta 45), reused 322 (delta 5), pack-reused 0 Receiving objects: 100% (5140/5140), 4.16 MiB | 1.01 MiB/s, done. Resolving deltas: 100% (45/45), done. Error: Invalid formula: /Users/hacosato/Library/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/diesel.rb undefined method `uses_from_macos' for #<Class:0x00007f9757899ae0> Error: Invalid formula: /Users/hacosato/Library/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/h2o.rb undefined method `uses_from_macos' for Formulary::FormulaNamespacec579bc6ee01a64170f1603f5fc3ebbad::H2o:Class (同じエラーが600行ほど) Error: Cannot tap homebrew/core: invalid syntax in tap! Error: Failure while executing: /Users/hacosato/Library/Homebrew/bin/brew tap homebrew/core hacosatonoiMac:~ hacosato$ brew install python3 Initialized empty Git repository in /Users/hacosato/Library/Homebrew/.git/ remote: Enumerating objects: 1967, done. Updating Homebrew...ects: 0% (1/1967) remote: Counting objects: 100% (1967/1967), done. remote: Compressing objects: 100% (1781/1781), done. remote: Total 1967 (delta 201), reused 713 (delta 102), pack-reused 0 Receiving objects: 100% (1967/1967), 2.01 MiB | 1.26 MiB/s, done. Resolving deltas: 100% (201/201), done. From https://github.com/Homebrew/brew * [new branch] master -> origin/master HEAD is now at 575f76a Merge pull request #7074 from dawidd6/log-homebrew-path To restore the stashed changes to /Users/hacosato/Library/Homebrew run: 'cd /Users/hacosato/Library/Homebrew && git stash pop' -e:1:in `<main>': undefined method `canonical_segments' for #<Gem::Version "2.3.7"> (NoMethodError) ==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.mavericks.bottle.tar.gz Already downloaded: /Users/hacosato/Library/Caches/Homebrew/portable-ruby-2.6.3.mavericks.bottle.tar.gz ==> Pouring portable-ruby-2.6.3.mavericks.bottle.tar.gz ==> Homebrew has enabled anonymous aggregate formulae and cask analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics No analytics have been recorded yet (or will be during this `brew` run). ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Tapping homebrew/core Cloning into '/Users/hacosato/Library/Homebrew/Library/Taps/homebrew/homebrew-core'... remote: Enumerating objects: 13, done. remote: Counting objects: 100% (13/13), done. remote: Compressing objects: 100% (9/9), done. remote: Total 684812 (delta 6), reused 11 (delta 4), pack-reused 684799 Receiving objects: 100% (684812/684812), 276.87 MiB | 526.00 KiB/s, done. Resolving deltas: 100% (448910/448910), done. Tapped 2 commands and 4922 formulae (5,182 files, 303.7MB). /Users/hacosato/Library/Homebrew/Library/Homebrew/brew.rb:10:in `<main>': Homebrew must be run under Ruby 2.6! You're running 2.3.7. (RuntimeError)
unlinkができていないでしょうか…?

回答3件
あなたの回答
tips
プレビュー