LoginSignup
5
6

More than 5 years have passed since last update.

python3にScrapyをインストール

Last updated at Posted at 2016-07-02

「PythonによるWebスクレイピング」を読んでいたら、一部でscrapyを使うことになったのだけど、うまくインストールできなかったので、その解決法を軽くまとめておきます
(ちなみに上記の本は主にBeautifulSoupを使ってスクレイピングします)

設定した環境

MacBook Air (13-inch, Mid 2011)
プロセッサ: 1.8 GHz Intel Core i7
メモリ: 4 GB 1333 MHz DDR3
バージョン: 10.11.5
Python: 3.6.2

Scrapyを入れてみる

1, 今回はPython3の環境に入れます。

$ pip3 install scrapy

すると…以下のエラーが出てしまいました。
どうやらpipのバージョンアップをすべきようです。

You are using pip version 8.1.1, however version 8.1.2 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

2, エラー文の指示に従って、pipをアップグレードします。

$ pip3 install --upgrade pip

ここでもまたエラーが…
今度はxcodeまわりのようです。

1 error generated.

*********************************************************************************

Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?

Perhaps try: xcode-select --install

*********************************************************************************

error: command '/usr/bin/clang' failed with exit status 1

3, 次もちょうど指示があるのでそれにならって、コマンドを打ちます。

$ xcode-select --install

xcode-select: note: install requested for command line developer tools

するとダイアログが表示されるので、同意してデベロッパーツールをDLをします。

スクリーンショット 2016-07-02 23.17.27.png


4, ダウンロード後にもう一度、以下を実行すれば、インストール完了です。

$ sudo pip3 install scrapy

(中略)

Installing collected packages: lxml, parsel, scrapy
  Running setup.py install for lxml ... done
Successfully installed lxml-3.6.0 parsel-1.0.2 scrapy-1.1.0
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6