質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
スクレイピング

スクレイピングとは、公開されているWebサイトからページ内の情報を抽出する技術です。

Jupyter

Jupyter (旧IPython notebook)は、Notebook形式でドキュメント作成し、プログラムの記述・実行、その実行結果を記録するツールです。メモの作成や保存、共有、確認などもブラウザ上で行うことができます。

Anaconda

Anacondaは、Python本体とPythonで利用されるライブラリを一括でインストールできるパッケージです。環境構築が容易になるため、Python開発者間ではよく利用されており、商用目的としても利用できます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

3634閲覧

JupyterLabでの"command not found: brew"に対処したい

TTSS

総合スコア6

スクレイピング

スクレイピングとは、公開されているWebサイトからページ内の情報を抽出する技術です。

Jupyter

Jupyter (旧IPython notebook)は、Notebook形式でドキュメント作成し、プログラムの記述・実行、その実行結果を記録するツールです。メモの作成や保存、共有、確認などもブラウザ上で行うことができます。

Anaconda

Anacondaは、Python本体とPythonで利用されるライブラリを一括でインストールできるパッケージです。環境構築が容易になるため、Python開発者間ではよく利用されており、商用目的としても利用できます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2021/05/27 02:24

編集2021/05/27 02:33

**M1 Mac(Big Sur)上のJupyterLab(ANACONDA.NAVIGATORで起動)にて、スクレイピングをするために、添付1のコードを入力して実行すると"command not found: brew"となります(添付1)。添付1
何がいけないのでしょうか。超初心者なので、お恥ずかしい状況かと思いますが、解決法をお教えいただければ幸いです。

1.homebrewは、https://www.teamxeppet.com/macbook-m1-homebrew-install/[リンク](https://www.teamxeppet.com/macbook-m1-homebrew-install/), https://brew.sh/[リンク](https://brew.sh/)に従ってインストールしました。この結果確認が添付2-1.、2-2.、2-3-1.〜2-3-3.です。
2-1.
2-1.
2-2.
2-2.
2-3-1.
2-3-1.
2-3-2.
2-3-2.
2-3-3.
2-3-3.

2.関連のディレクトリについては、添付3-1.、3-2.の通りです。
3-1.
3-1.
3-2.
3-2.

  1. .zprofile、.zshrcは添付4-1.、4-2.の通りです。

4-1. .zprofile
4-1.
4-2. .zshrc
4-2.

4.ターミナルでbrewを実行した状況は、添付5.の通りです。
添付5. ターミナルでbrewを実行
5.

ご教授をお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2021/05/27 02:56

arm64とx86-64が混在している感じでしょうか M1向けの導入記事などは参考にしましたか?
jbpb0

2021/05/27 03:09

jupyterで !brew... で実行するのではなく、ターミナルで brew install chromedriver とやればいいのでは??
TTSS

2021/05/27 03:18

userisgod様  コメントありがとうございます。できるだけ、M1向けの記事を参考にしたつもりですが、メインのコードについては、インテルCPUを前提としたものです。
TTSS

2021/05/27 03:49

jbpb0様  コメントありがとうございます。ターミナルでbrew install chromedriver をやると、次の反応です。 ーーーーーーーーーーーーーーーーーー Updating Homebrew... ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/cask). ==> New Formulae universal-ctags ==> Updated Formulae Updated 74 formulae. ==> Updated Casks Updated 55 casks. Warning: Cask 'chromedriver' is already installed. To re-install chromedriver, run: brew reinstall chromedriver ーーーーーーーーーーーーーーーーーー この後、JupyterLabでbowser=webdriver.chrome( )を実行すると、 TypeError: 'module' object is not callableの結果となります。
jbpb0

2021/05/27 03:55

> 'chromedriver' is already installed. chromedriverはすでにインストールされているので、jupyterで !brew... を行う必要はありません それを実行して > command not found: brew というエラーが出ることは、その次の > JupyterLabでbowser=webdriver.chrome( )を実行すると、 TypeError: 'module' object is not callable となることとは関係ありません
TTSS

2021/05/27 04:16 編集

jbpb0様  再度のコメントありがとうございます。基本的枠組みが分からずに、お手数をかけているのかと思います。恐縮です。ターミナルでbrew install chromedriverした後には、jupyterで!brew...は実行していません。それをせずに JupyterLabでbowser=webdriver.chrome( )を実行して、TypeError: 'module' object is not callableの結果となっています。JupyterLabでのfrom selenium import webdriverの実行にはエラーが出ませんので、webdriverは使えるようになっていると認識しているのですが。
quickquip

2021/05/27 05:14

解決したい問題が「command not found: brew と出ること」なのかそれ以外なのかが不明瞭に思います。 前者なら、 ターミナルで which brew を実行した結果 jupyterで !echo $PATH を実行した結果 を見比べるのがよさそうに思いました。
TTSS

2021/05/27 07:59

quickquip様  さらにコメントありがとうございます。 まずは、前者を解決してbowser=webdriver.chrome( )を実行してchoromeを立ち上げたいと思っています。そこでお教えいただいた実行の結果は次の通りでした。 ・ターミナルで which brew を実行した結果:/opt/homebrew/bin/brew ・jupyterで !echo $PATH を実行した結果:/Users/user名/opt/anaconda3/bin:/Users/user名opt/anaconda3/condabin:/usr/bin:/bin:/usr/sbin:/sbin  それではと、jupyterで!/opt/homebrew/bin/brew install chromedriverを実行したところ、 ーーーーーーーーーーーーーーーーーー Warning: Cask 'chromedriver' is already installed. To re-install chromedriver, run: brew reinstall chromedriver ーーーーーーーーーーーーーーーーーー となって、chromedriverがインストールできたようなので、続いて、 jupyterでbrowser = webdriver.Chrome()を実行(chromeeのcは大文字に して)すると次のメッセージが出ました。 --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) ~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/common/service.py in start(self) 71 cmd.extend(self.command_line_args()) ---> 72 self.process = subprocess.Popen(cmd, env=self.env, 73 close_fds=platform.system() != 'Windows', ~/opt/anaconda3/lib/python3.8/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text) 853 --> 854 self._execute_child(args, executable, preexec_fn, close_fds, 855 pass_fds, cwd, env, ~/opt/anaconda3/lib/python3.8/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) 1701 err_msg = os.strerror(errno_num) -> 1702 raise child_exception_type(errno_num, err_msg, err_filename) 1703 raise child_exception_type(err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver' During handling of the above exception, another exception occurred: WebDriverException Traceback (most recent call last) <ipython-input-25-78b07196e7cd> in <module> ----> 1 browser = webdriver.Chrome() ~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive) 71 service_args=service_args, 72 log_path=service_log_path) ---> 73 self.service.start() 74 75 try: ~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/common/service.py in start(self) 79 except OSError as err: 80 if err.errno == errno.ENOENT: ---> 81 raise WebDriverException( 82 "'%s' executable needs to be in PATH. %s" % ( 83 os.path.basename(self.path), self.start_error_message) WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home --------------------------------------------------------------------------- 以上で、行き詰まってしまいました。
jbpb0

2021/05/27 09:26 編集

> No such file or directory: 'chromedriver' brew install chromedriver でインストールしたchromedriverがMacのどこにあるのかを探して、 webdriver.Chrome() を webdriver.Chrome(executable_path='chromedriverの絶対パス') に変えてください webdriver.Chrome(executable_path='/usr/local/bin/chromedriver') みたいに
TTSS

2021/05/27 10:25 編集

jbpb0様  ありがとうございます。お教えの通りで解決しました。 下線以下の通りにしましたが、その後、ご指示の通りにするには、 browser = webdriver.Chrome(executable_path='/opt/homebrew/bin/')を browser = webdriver.Chrome(executable_path='/opt/homebrew/bin/chromedriver')にする 必要があることに気がつき修正しました。 その後、chromedriverを開いて良いかどうかセキュリティの確認が出ましたが、システム環境設定の セキュリティとプライバシーの設定で開く許可を出したら、動ききました。 ありがとうございます。感謝の言葉もありません。 ーーーーーーーーーーーーーーーーーーーーーー  再三のアドバイスありがとうございます。 ・ターミナルでの実行と結果 ~ % which chromedriver /opt/homebrew/bin/chromedriver ・Jupyterでの実行: browser = webdriver.Chrome(executable_path='/opt/homebrew/bin/') ・結果:Permission denied: '/opt/homebrew/bin/'とのことですが、どう 対応したら良いか分かりません。 --------------------------------------------------------------------------- PermissionError Traceback (most recent call last) ~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/common/service.py in start(self) 71 cmd.extend(self.command_line_args()) ---> 72 self.process = subprocess.Popen(cmd, env=self.env, 73 close_fds=platform.system() != 'Windows', ~/opt/anaconda3/lib/python3.8/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text) 853 --> 854 self._execute_child(args, executable, preexec_fn, close_fds, 855 pass_fds, cwd, env, ~/opt/anaconda3/lib/python3.8/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) 1701 err_msg = os.strerror(errno_num) -> 1702 raise child_exception_type(errno_num, err_msg, err_filename) 1703 raise child_exception_type(err_msg) PermissionError: [Errno 13] Permission denied: '/opt/homebrew/bin/' During handling of the above exception, another exception occurred: WebDriverException Traceback (most recent call last) <ipython-input-8-eb02f8b51d3d> in <module> ----> 1 browser = webdriver.Chrome(executable_path='/opt/homebrew/bin/') ~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive) 71 service_args=service_args, 72 log_path=service_log_path) ---> 73 self.service.start() 74 75 try: ~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/common/service.py in start(self) 84 ) 85 elif err.errno == errno.EACCES: ---> 86 raise WebDriverException( 87 "'%s' executable may have wrong permissions. %s" % ( 88 os.path.basename(self.path), self.start_error_message) WebDriverException: Message: '' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home --------------------------------------------------------------------------- 「子供使い」のような初心者で大変恐縮ですが、お教えいただければとても ありがたいです。
jbpb0

2021/05/27 10:19

webdriver.Chrome(executable_path='/opt/homebrew/bin/') ↓ webdriver.Chrome(executable_path='/opt/homebrew/bin/chromedriver')
TTSS

2021/05/27 10:26

jbpb0様  行き違いとなりましたが、ご指示の通りで解決しました。 ありがとうございます。
guest

回答1

0

ベストアンサー

'module' object is not callable

これ見てください
python3,chromeのスクレイピングについて

 .

No such file or directory: 'chromedriver'

となったら、
brew install chromedriver
でインストールした「chromedriver」がMacのどこにあるのかを探して、

python

1webdriver.Chrome()

の部分を

python

1webdriver.Chrome(executable_path='chromedriverの絶対パス')

に変えてください
たとえば、

python

1webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')

みたいに

投稿2021/05/27 05:56

編集2021/05/27 10:41
jbpb0

総合スコア7653

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

TTSS

2021/05/27 11:23

最終的にここまでのご指南に従って、解決しました。超初心者へのお付き合い、心より感謝いたします。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問