CentOS 7安装python3及Scrapy(linux环境下scrapy爬虫学习环境配置)

1、安装依赖包

yum -y groupinstall "Development tools"

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,我下载的是Python3.6.2

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

3、解压压缩包,进入该目录,安装Python3

tar -xvJf  Python-3.6.2.tar.xz

 4、进行Python3的编译安装(其中=后为安装的路径)

./configure --prefix=/usr/python3
make
make install

5、添加软链到执行目录下/usr/bin

ln -s /usr/python3/bin/python3.6 /usr/bin/python3
ln -s /usr/python3/bin/pip3 /usr/bin/pip3

6、查看python和pip的版本

python3 --version
pip3 --version

安装scrapy

1、pip安装

pip3 install scrapy

判断是否有错误比如缺少ssl

使用命令:

sudo yum install -y openssl-devel

进行安装,安装完成后用命令添加到python

./configure --prefix=/usr/python3 --with-ssl

2、出现Successfully表明安装成功

3、添加到.bsahrc文件

CentOS 7安装python3及Scrapy(linux环境下scrapy爬虫学习环境配置)_第1张图片

9、编译.bsahrc文件及python3、scrapy.出现如下图即成功

source .bashrc
python3
scrapy

CentOS 7安装python3及Scrapy(linux环境下scrapy爬虫学习环境配置)_第2张图片

你可能感兴趣的:(python)