代码改变世界

centos安装httprunner方法

2019-12-06 15:29  Tanwheey  阅读(604)  评论(0编辑  收藏  举报

测试脚本执行的环境部署(在jenkins服务器中,要求jenkins服务器和目标的灰度环境是连通的):

一、安装python3.8

$python#看见2.6.6
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
$which python#查看python位置,一般是位于/usr/bin/python目录下

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

进官网:https://www.python.org/downloads/source/

# wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

(最好不要安装最新版:wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz)

3.安装python3

创建目录:

# mkdir -p /usr/local/python3

解压下载好的Python-3.x.x.tgz包

# tar -zxvf Python-3.8.0.tgz

进入解压后的目录,编译安装:

# cd Python-3.8.0

# ./configure --prefix=/usr/local/python3

# make && make install

4.建立python3的软链,创建软链接文件到执行文件路径

# ln -s /usr/local/python3/bin/python3 /usr/bin/python3

# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

报错:

ln: creating symbolic link `/usr/bin/pip3': File exists,

解决办法:

1)强制覆盖之前的软链:

 ln -sf /usr/local/python3/bin/python3 /usr/bin/python3

ln -sf /usr/local/python3/bin/pip3 /usr/bin/pip3

2)或删除软连接:rm /usr/bin/pip3

3)或清除之前编译的可执行文件及配置文件 && 清除所有生成的文件:

make clean && make distclean

5.并将/usr/local/python3/bin加入PATH

 

vim /etc/profile #使用su切换回要添加环境变量的用户,修改环境变量

在文档最后添加地址:

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

export PATH

,保存后退出

$ source /etc/profile #生效环境变量

测试是否安装成功:

  • pip3 -V
  • python3 -V

 

# 安装自动化测试框架

# pip3 install httprunner

pip升级:

WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

pip install --upgrade pip

 如有报错,https://pypi.org/simple/pip/下载最新版安装:

 

WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

# 看是否安装成功

[root@jenkins:~]# httprunner -V

2.2.4

 

 

------------------------------------------------------Tanwheey--------------------------------------------------

爱生活,爱工作。