python scrapy对抓取数据后的存储 sqilte3的安装
2013-05-05 01:03
861 查看
对于抓取数据量,链接数不是很大的情况下,可以选sqlite作为存储数据库。sqlite轻巧,操作方便,快速。不像mysql那样庞大。
centos下python2.7 scrapy0.16 ,默认情况下,没有sqlite模块,我们要自己安装。
用easy_install 装,安装完后,import,出错了!,如下
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python2.7.4/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/python2.7.4/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
网上搜到解决方案是:重装python,重新编译,好吧,照做就是了,可编译python过程又出现问题了。。,如下:
Python build finished, but the necessary bits to build these modules were not found:
_tkinter bsddb185 sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
_sqlite3
再到网上找解决方案:
在./Modules/_sqlite/connection.c 文件中加入红色部分
#include "cache.h"
#include "module.h"
#include "connection.h"
#include "statement.h"
#include "cursor.h"
#include "prepare_protocol.h"
#include "util.h"
#include "sqlitecompat.h"
#include "pythread.h"
#define ACTION_FINALIZE 1
#define ACTION_RESET 2
#if SQLITE_VERSION_NUMBER >= 3003008
#ifndef SQLITE_OMIT_LOAD_EXTENSION
#define HAVE_LOAD_EXTENSION
#endif
#endif
#ifdef SQLITE_INT64_TYPE
typedef SQLITE_INT64_TYPE sqlite_int64;
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 sqlite_int64;
typedef unsigned __int64 sqlite_uint64;
#else
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;
重新make,还是failed
网上又找到方法,如下:
安装sqlite3
下载 sqlite (如sqlite-amalgamation-3.6.20.tar.gz)
下载地址:http://www.sqlite.org/sqlite-amalgamation-3.6.20.tar.gz
安装sqlite, 如果要安装到用户指定目录,可以: $./configure --prefix=/your/path/(我用的/usr/local)
安装sqlite成功,import一下,还是不行,于是又到Python2.7安装目录下make,这次 竟然make通过了,没报failed,然后make install。
等一会儿,python装完了,再import sqlite3,成功了,额滴个神啊,终于搞定了。。。。
参考网站:
1.http://gcxieblog.blog.163.com/blog/static/56837839200911105418606/
2.http://blog.csdn.net/chenggong2dm/article/details/7692826
centos下python2.7 scrapy0.16 ,默认情况下,没有sqlite模块,我们要自己安装。
用easy_install 装,安装完后,import,出错了!,如下
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python2.7.4/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/python2.7.4/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
网上搜到解决方案是:重装python,重新编译,好吧,照做就是了,可编译python过程又出现问题了。。,如下:
Python build finished, but the necessary bits to build these modules were not found:
_tkinter bsddb185 sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
_sqlite3
再到网上找解决方案:
在./Modules/_sqlite/connection.c 文件中加入红色部分
#include "cache.h"
#include "module.h"
#include "connection.h"
#include "statement.h"
#include "cursor.h"
#include "prepare_protocol.h"
#include "util.h"
#include "sqlitecompat.h"
#include "pythread.h"
#define ACTION_FINALIZE 1
#define ACTION_RESET 2
#if SQLITE_VERSION_NUMBER >= 3003008
#ifndef SQLITE_OMIT_LOAD_EXTENSION
#define HAVE_LOAD_EXTENSION
#endif
#endif
#ifdef SQLITE_INT64_TYPE
typedef SQLITE_INT64_TYPE sqlite_int64;
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 sqlite_int64;
typedef unsigned __int64 sqlite_uint64;
#else
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;
重新make,还是failed
网上又找到方法,如下:
安装sqlite3
下载 sqlite (如sqlite-amalgamation-3.6.20.tar.gz)
下载地址:http://www.sqlite.org/sqlite-amalgamation-3.6.20.tar.gz
安装sqlite, 如果要安装到用户指定目录,可以: $./configure --prefix=/your/path/(我用的/usr/local)
安装sqlite成功,import一下,还是不行,于是又到Python2.7安装目录下make,这次 竟然make通过了,没报failed,然后make install。
等一会儿,python装完了,再import sqlite3,成功了,额滴个神啊,终于搞定了。。。。
参考网站:
1.http://gcxieblog.blog.163.com/blog/static/56837839200911105418606/
2.http://blog.csdn.net/chenggong2dm/article/details/7692826
相关文章推荐
- 【Python入门只需20分钟】从安装到数据抓取、存储原来这么简单
- Python Scrapy抓取数据
- 【Python笔记】WEB抓取框架Scrapy的安装方法
- 【Scrapy】 使用 python 抓取新浪微博 数据
- Scrapy:Python3版本上安装数据挖掘必备的scrapy框架详细攻略(二最完整爬取网页内容信息攻略)——Jason niu
- Python爬虫框架Scrapy实战之抓取户外数据
- 数据可视化 三步走(一):数据采集与存储,利用python爬虫框架scrapy爬取网络数据并存储
- python处理scrapy抓取生成的json数据遇到的问题
- Scrapy:Python3版本上安装数据挖掘必备的scrapy框架详细攻略(一)——Jason niu
- 利用python scrapy 框架抓取豆瓣小组数据
- 安装 Scrapy python抓取工具
- python 开源数据抓取框架scrapy
- python,scrapy爬虫sql之爬取数据存储到mysql的piplelines.py配置
- 安装MySql+连接数据库+读取数据并存储成dataframe(python3.6)
- python序列化(数据本地存放持久性存储)和反序列化
- 学习笔记-python抓取网页数据
- python数据持久存储:pickle模块的基本使用 分类: python python基础学习 python 小练习 2013-06-17 14:41 209人阅读 评论(0) 收藏
- Python+Selenium实现股票板块数据模拟抓取
- python scrapy 的概念、安装、使用和案例
- python scrapy安装