[asin:4774183679:detail]

上記の本でスクレイピングを勉強中。

PythonからMySQLに接続するmysqlclientのインストール時に躓いたのでメモ。

環境Vagrant上のUbuntu python3.4.3

インストールのために以下コマンドを実行。

|bash| $ pip install mysqlclient ||<

するとエラーが出てくる。

|bash| _mysql.c:40:20: fatal error: Python.h: No such file or directory

#include “Python.h”

                ^

compilation terminated.

error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1 ||<

ライブラリが足りていないようなので、以下コマンドを実行。

|| $ sudo apt-get install python3-dev ||<

そのあともう一度インストールするとうまくいきました。

|bash| $ pip install mysqlclient ||<