zsh: command not found: brew

MAC
本ページはプロモーションが含まれています

はじめに

最近MacbookProを新しいものに買い替えました。
これまで作成していたプログラムは残っているのですが、作成していた時にインストールした諸々がなくなってほとんどのプログラムが動かなくなってしまい…

エラーメッセージ

Mac上でPythonのOCRのプログラムを動かすためのtesseractをインストールしようと、

brew install tesseract

コマンドを実行するも、

zsh: command not found: brew

というエラーメッセージが。
『brewなんてコマンド見つからないよ』と言ってます。

僕自身正直Macを使ってまだそれほど日が長くない(まだまだ慣れた感じがしない)ので、ちょっと調べたのでその結果をメモとして残します。

brewとは

そもそもbrewとはですが、wikipediaによると

Homebrewは、macOS、Linux、Windows Subsystem for Linuxで動作するパッケージ管理システムのひとつである[3]。同じくmacOSのためのMacPortsやFinkと同様の目的と機能を備え、利用が広がりつつある。LinuxのDebianのAPTに似た使用感である。Max Howellによって開発された。

とのことでパッケージ管理システムです。
パッケージ管理システムはプログラムのインストールやバージョンなどの管理を代わりに行ってくれるものです。
brewはそのMac上で動くパッケージ管理システムになるようです。

brewのインストール

無いものは追加するしかないのでインストールしました。
手順はこのサイトを参考にさせていただきました。
ありがとうございますm(_ _)m

Macのターミナルを開いて

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

と入力します。
インストールが始まります。

==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
・
・
【省略】
・
・
* [new branch] master -> origin/master
HEAD is now at 658afc90138 djl-serving: update 0.20.0 bottle.
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
Anonymous Analytics
Documentation for the missing package manager for macOS (or Linux).
No analytics data has been sent yet (nor will any be during this install run). ==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
GitHub - Homebrew/brew: 🍺 The missing package manager for macOS (or Linux)
🍺 The missing package manager for macOS (or Linux) - Homebrew/brew
==> Next steps: - Run these three commands in your terminal to add Homebrew to your PATH: echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /Users/*****/.zprofile echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/*****/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" - Run brew help to get started - Further documentation:
Documentation
Documentation for the missing package manager for macOS (or Linux).

インストールは正しく出来たと表示されていますが、どうもメッセージを見ると(「==> Next steps:」の部分です)パスが通っていないようです。

インストールが正しく行えているかの動作確認は

brew -v

コマンドで行います。

コマンドを入力すると最初と同じく

zsh: command not found: brew

というエラーメッセージが。

brewインストール時にメッセージにNextstepの手順が書かれています。
(*****部分は変更しています)

echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /Users/******/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/*****/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

次はこれをターミナル上で実行しました。
echo部分から実行して下さい。
実行するのは2行分でした。

echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /Users/*****/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/*****/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)" 

再び、インストールが成功しているか確認すると

Homebrew 3.6.14
Homebrew/homebrew-core (git revision 658afc90138; last commit 2022-12-11)

と無事インストールが出来ていました。
これでbrewのインストールは完了です。

最後に

インストールしたばかりなどはこう入ったメッセージが表示されるのではないかと。
brewはプログラムをMacでするなら必要なパッケージ管理ソフトですので、インストール推奨です。

ただ、僕もですが、こういった環境設定て難しいので、初心者の方などは、このあたりはつまづくかと(特に独学とかなら尚更ですね)

ということで、この記事がお役に立ったのなら嬉しいです。

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

タイトルとURLをコピーしました