CentOS 7下Python+robot framework环境搭建

以下用到的包可在网盘下载,也可自行到网页内下载最新版,目前网盘内均为最新版本

https://pan.baidu.com/s/1c2tZfaS

密码:qxwe

下载好后可以用SecureFX上传至服务器中

一、安装Python

python下载地址:

https://www.python.org/downloads/

安装python

[root@centos7 mnt]# tar -zvxf Python-3.6.4.tgz

[root@centos7 mnt]# mkdir /usr/local/python3.6

[root@centos7 mnt]# cd Python-3.6.4

[root@centos7 Python-3.6.4]# ./configure --prefix=/usr/local/python3.6

如果报以下错误:


CentOS 7下Python+robot framework环境搭建_第1张图片

解决方法:安装gcc

配置好本地yum源后,安装gcc

[root@centos7 yum.repos.d]# yum install gcc

继续安装python

[root@centos7 Python-3.6.4]# ./configure --prefix=/usr/local/python3.6 --enable-optimizations

......

[root@centos7 Python-3.6.4]# make && make install

如果编译过程中有出现"zipimport.ZipImportError: can't decompress data; zlib not available"错误提示,如下图:

CentOS 7下Python+robot framework环境搭建_第2张图片

解决方法:yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel make

不能忽略相关包,我之前就没有安装readline-devel导致执行python模式无法使用键盘的上下左右键;

重新make && make install

mv python python.bak #备份原来的python

ln -s /usr/local/python3.6/bin/python3.6 /usr/bin/python #关联系统默认版本为python3.6

查看Python版本

python –V

修改yum配置(否则yum无法正常运行)

vi /usr/bin/yum

将第一行的#!/usr/bin/python修改为系统新的地址#!/usr/bin/python2

同理 vi /usr/libexec/urlgrabber-ext-down 文件里面的#! /usr/bin/python 也要修改为#! /usr/bin/python2

二、安装robotframework

robotframework下载地址:

https://pypi.python.org/pypi/robotframework#downloads

安装robotframework

[root@centos7 mnt]# tar -zvxf robotframework-3.0.2.tar.gz

[root@centos7 mnt]# chmod 755 robotframework-3.0.2

[root@centos7 mnt]# cd robotframework-3.0.2

[root@centos7 robotframework-3.0.2]# python setup.py install

……

查看是否安装成功

[root@centos7 robotframework-3.0.2]# pybot --version

Robot Framework 3.0.2 (Python 3.6.4 on linux2)

问题:robotframework都安装到哪里了?

[root@centos7 robotframework-2.9]# find / -name robot


四、安装robotframework-selenium2library

robotframework-selenium2library下载地址

https://pypi.python.org/pypi/robotframework-selenium2library/


[root@centos7 mnt]# tar -zvxf robotframework-selenium2library-3.0.0

[root@centos7 mnt]# chmod 755 robotframework-selenium2library-3.0.0

[root@centos7 mnt]# cd robotframework-selenium2library-3.0.0

[root@centos7  robotframework-selenium2library-3.0.0]# python setup.py install

检测Selenium2Library是否安装成功

[root@centos7   robotframework-selenium2library-3.0.0]# python


CentOS 7下Python+robot framework环境搭建_第3张图片

>>> import Selenium2Library

>>>

如上,没报错,则说明安装成功

你可能感兴趣的:(CentOS 7下Python+robot framework环境搭建)