亲宝软件园·资讯

展开

CentOS安装python3.5+scrapy CentOS下安装python3.5+scrapy的方法步骤

Beng 人气:0
想了解CentOS下安装python3.5+scrapy的方法步骤的相关内容吗,Beng在本文为您仔细讲解CentOS安装python3.5+scrapy的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:CentOS安装python3.5,scrapy,python3,scrapy安装,下面大家一起来学习吧。

前言:不用改掉系统python2.7 ,原来是python2.7,我们还进行python2.7的保留

1.编译前准备其他库的安装(使用sudo命令)

[root@hadron ~]# yum -y groupinstall "Development tools" 

[root@hadron ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

2.下载python3安装压缩包->解压->进入目录->编译->安装

[root@hadron ~]# wget https://www.python.org/ftp/python/3.5.5/Python-3.5.5.tgz
[root@hadron ~]# tar -zxvf Python-3.5.5.tgz 
[root@hadron ~]# cd Python-3.5.5/
[**加粗文字**root@hadron ~]# ./configure --prefix=/usr/local/python3
[root@hadron ~]# make && make install

3.创建Python3,pip3的软链接

[root@hadron ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@hadron ~]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

4.验证Python3 和pip3 是否安装成功

[root@hadron ~]# python
Python 2.7.5 (default, Nov 6 2016, 00:28:07) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
[root@hadron ~]# python3
Python 3.5.5 (default, Feb 27 2018, 09:28:49) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
[root@hadron ~]# 

[root@hadron ~]# pip3 --version
pip 9.0.1 from /usr/local/python3/lib/python3.5/site-packages (python 3.5)

5.安装Scrapy爬虫框架

安装过程中如果出现红色代码,可能是网络原因,请试多几次

[root@hadron ~]# pip3 install scrapy

6. 验证是否安装成功

[root@hadron ~]# python3
[root@hadron ~]# >>>import scrapy
[root@hadron ~]# >>>

上面也是验证Scrapy框架安装成功,因为我们进行了import scrapy没有进行报错。

7.创建Scrapy软链接

[root@hadron ~]# ln -s /usr/local/python3/bin/scrapy /usr/bin/scrapy

8. 验证Scrapy软链接

[root@hadron ~]# scrapy -v
Scrapy 1.5.0 - no active project

加载全部内容

相关教程
猜你喜欢
用户评论