python

关注公众号 jb51net

关闭
首页 > 脚本专栏 > python > 安装Scrapy模块依赖包汇总

python中安装Scrapy模块依赖包汇总

作者:lon.y@qq.com

Scrapy的安装有一些依赖包,没有这些包是会安装失败的,下面我们就来详细探讨下

本地虚拟环境开发完成之后,上线过程中需要一一安装依赖包,做个记录如下:

CentOS 安装python3.5.3

wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
tar -xf Python-3.5.3.tgz cd Python-3.5.3
./configure --prefix=/usr/local/python353 make & make install

完成安装python3.5.3,在不删除系统自带的python2.x情况下,做几个软链:

#做python3软链
ln -s /usr/local/python353/bin/python3 /usr/local/bin/
#pip3软链
ln -s /usr/local/python353/bin/pip3 /usr/local/bin/

上传程序,安装scrapy及其依赖包:

#user agent包
pip3 install fake-useragent -i https://pypi.douban.com/simple/
#pymysql包
pip3 install pymysql -i https://pypi.douban.com/simple/
#PooledDB依赖包
pip3 install DBUtils -i https://pypi.douban.com/simple/
#PIL模块依赖包
pip3 install Image -i https://pypi.douban.com/simple/

在Centos系统中安装过程中,出现一个较为淡疼的问题:系统没有安装sqlite3,故此一直提示:
解决上面问题,下载sqlite3

sudo wget http://www.sqlite.org/2017/sqlite-autoconf-3190300.tar.gz

编译安装:

tar zxvf sqlite-autoconf-3190300.tar.gz cd sqlite-autoconf-3190300
./configure --prefix=/usr/local/sqlite3
make && make install

重新编译Python,找到Python3.5.3的安装文件路径,编辑setup.py脚本,找到 “sqlite3”

sqlite_inc_paths = [ '/usr/include',
'/usr/include/sqlite',
'/usr/include/sqlite3',
'/usr/local/include',
'/usr/local/include/sqlite',
'/usr/local/include/sqlite3',
]

在最后一行加入sqlite3编译安装路径,如下:

sqlite_inc_paths = [ '/usr/include',
'/usr/include/sqlite',
'/usr/include/sqlite3',
'/usr/local/include',
'/usr/local/include/sqlite',
'/usr/local/include/sqlite3',
'/usr/local/sqlite3',
]

重新编译Python3.5.3:

./configure --prefix=/usr/local/python353
make && make install

您可能感兴趣的文章:
阅读全文