脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - 基于Python在MacOS上安装robotframework-ride

基于Python在MacOS上安装robotframework-ride

2021-05-09 00:31liumiaocn Python

今天小编就为大家分享一篇关于基于Python在MacOS上安装robotframework-ride,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧

robotframework是一个框架,是一个可以用于关键字测试驱动的框架。而ride(robotframework-ride)就是可以使得写robot测试用例更加方便快捷的ide图形操作工具。

安装

因为是基于python的,所以其可以运行在多个操作系统上。这里主要介绍一下ride在macos上的使用方式。

os版本

macos版本:10.13.2

wxpython

由于ride是基于wxpython的应用,所以首先需要保证wxpython已经得到了安装。安装命令如下:

安装命令:brew install wxpython

安装日志

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
liumiaocn:~ liumiao$ brew install wxpython
==> installing dependencies for wxpython: gdbm, readline, sqlite, python@2, jpeg, libpng, libtiff, wxmac
==> installing wxpython dependency: gdbm
==> downloading https://homebrew.bintray.com/bottles/gdbm-1.15.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> pouring gdbm-1.15.high_sierra.bottle.tar.gz
? /usr/local/cellar/gdbm/1.15: 19 files, 569.8kb
==> installing wxpython dependency: readline
==> downloading https://homebrew.bintray.com/bottles/readline-7.0.3_1.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> pouring readline-7.0.3_1.high_sierra.bottle.tar.gz
==> caveats
this formula is keg-only, which means it was not symlinked into /usr/local,
because macos provides the bsd libedit library, which shadows libreadline.
in order to prevent conflicts when programs look for libreadline we are
defaulting this gnu readline installation to keg-only.
for compilers to find this software you may need to set:
  ldflags: -l/usr/local/opt/readline/lib
  cppflags: -i/usr/local/opt/readline/include
==> summary
? /usr/local/cellar/readline/7.0.3_1: 46 files, 1.5mb
==> installing wxpython dependency: sqlite
==> downloading https://homebrew.bintray.com/bottles/sqlite-3.24.0.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> pouring sqlite-3.24.0.high_sierra.bottle.tar.gz
==> caveats
this formula is keg-only, which means it was not symlinked into /usr/local,
because macos provides an older sqlite3.
if you need to have this software first in your path run:
 echo 'export path="/usr/local/opt/sqlite/bin:$path"' >> ~/.bash_profile
for compilers to find this software you may need to set:
  ldflags: -l/usr/local/opt/sqlite/lib
  cppflags: -i/usr/local/opt/sqlite/include
for pkg-config to find this software you may need to set:
  pkg_config_path: /usr/local/opt/sqlite/lib/pkgconfig
==> summary
? /usr/local/cellar/sqlite/3.24.0: 11 files, 3.5mb
==> installing wxpython dependency: python@2
==> downloading https://homebrew.bintray.com/bottles/python@2-2.7.15_1.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> pouring python@2-2.7.15_1.high_sierra.bottle.tar.gz
==> /usr/local/cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-mana
==> /usr/local/cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-mana
==> /usr/local/cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-mana
==> caveats
pip and setuptools have been installed. to update them
 pip install --upgrade pip setuptools
you can install python packages with
 pip install <package>
they will install into the site-package directory
 /usr/local/lib/python2.7/site-packages
see: https://docs.brew.sh/homebrew-and-python
==> summary
? /usr/local/cellar/python@2/2.7.15_1: 4,673 files, 82.8mb
==> installing wxpython dependency: jpeg
==> downloading https://homebrew.bintray.com/bottles/jpeg-9c.high_sierra.bottle.tar.gz
curl: (6) could not resolve host: akamai.bintray.com
error: failed to download resource "jpeg"
download failed: https://homebrew.bintray.com/bottles/jpeg-9c.high_sierra.bottle.tar.gz
warning: bottle installation failed: building from source.
==> downloading http://www.ijg.org/files/jpegsrc.v9c.tar.gz
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/cellar/jpeg/9c
==> make install
? /usr/local/cellar/jpeg/9c: 21 files, 749.8kb, built in 33 seconds
==> installing wxpython dependency: libpng
==> downloading https://homebrew.bintray.com/bottles/libpng-1.6.34.high_sierra.bottle.tar.gz
curl: (6) could not resolve host: akamai.bintray.com
error: failed to download resource "libpng"
download failed: https://homebrew.bintray.com/bottles/libpng-1.6.34.high_sierra.bottle.tar.gz
warning: bottle installation failed: building from source.
==> downloading https://downloads.sourceforge.net/libpng/libpng-1.6.34.tar.xz
==> downloading from https://downloads.sourceforge.net/project/libpng/libpng16/1.6.34/libpng-1.6.34.tar.xz
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/cellar/libpng/1.6.34
==> make
==> make test
==> make install
? /usr/local/cellar/libpng/1.6.34: 26 files, 1.2mb, built in 1 minute 38 seconds
==> installing wxpython dependency: libtiff
==> downloading https://homebrew.bintray.com/bottles/libtiff-4.0.9_3.high_sierra.bottle.tar.gz
curl: (6) could not resolve host: akamai.bintray.com
error: failed to download resource "libtiff"
download failed: https://homebrew.bintray.com/bottles/libtiff-4.0.9_3.high_sierra.bottle.tar.gz
warning: bottle installation failed: building from source.
==> downloading https://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz
curl: (28) resolving timed out after 5551 milliseconds
trying a mirror...
==> downloading https://fossies.org/linux/misc/tiff-4.0.9.tar.gz
#########################                         34.8%
######################################################################## 100.0%
==> downloading https://mirrors.ocf.berkeley.edu/debian/pool/main/t/tiff/tiff_4.0.9-5.debian.tar.xz
######################################################################## 100.0%
==> patching
==> applying patches/cve-2017-9935.patch
patching file libtiff/tif_dir.c
patching file tools/tiff2pdf.c
==> applying patches/cve-2017-18013.patch
patching file libtiff/tif_print.c
==> applying patches/cve-2018-5784.patch
patching file contrib/addtiffo/tif_overview.c
patching file tools/tiff2pdf.c
patching file tools/tiffcrop.c
==> applying patches/cve-2017-11613_part1.patch
patching file libtiff/tif_dirread.c
==> applying patches/cve-2017-11613_part2.patch
patching file libtiff/tif_dirread.c
==> applying patches/cve-2018-7456.patch
patching file libtiff/tif_dirread.c
patching file libtiff/tif_print.c
==> applying patches/cve-2017-17095.patch
patching file tools/pal2rgb.c
==> ./configure --prefix=/usr/local/cellar/libtiff/4.0.9_3 --without-x --with-jpeg-include-dir=/usr/local/opt/jpeg/include --with-jpeg-
==> make install
? /usr/local/cellar/libtiff/4.0.9_3: 246 files, 3.5mb, built in 5 minutes 10 seconds
==> installing wxpython dependency: wxmac
==> downloading https://homebrew.bintray.com/bottles/wxmac-3.0.4.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> pouring wxmac-3.0.4.high_sierra.bottle.tar.gz
? /usr/local/cellar/wxmac/3.0.4: 810 files, 23.7mb
==> installing wxpython
==> downloading https://homebrew.bintray.com/bottles/wxpython-3.0.2.0_1.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> pouring wxpython-3.0.2.0_1.high_sierra.bottle.tar.gz
? /usr/local/cellar/wxpython/3.0.2.0_1: 1,108 files, 37.9mb
liumiaocn:~ liumiao$

版本确认

?
1
2
3
4
5
6
7
8
9
10
liumiaocn:~ liumiao$ brew info wxpython
wxpython: stable 3.0.2.0 (bottled)
python bindings for wxwidgets
https://www.wxwidgets.org/
/usr/local/cellar/wxpython/3.0.2.0_1 (1,115 files, 39.9mb) *
 poured from bottle on 2018-06-19 at 15:52:25
from: https://github.com/homebrew/homebrew-core/blob/master/formula/wxpython.rb
==> dependencies
required: python@2 ✔, wxmac ✔
liumiaocn:~ liumiao$

暂定对应1:wxpython安装之后,目前的版本还缺少一个软连接才能正常动作,根据日志可以看到此次安装的wxpython版本为wxpython-3.0.2.0_1, 按照如下操作创建软连接即可

创建链接

?
1
2
3
4
5
6
liumiaocn:bin liumiao$ pwd
/usr/local/bin
liumiaocn:bin liumiao$ ls wx
ls: wx: no such file or directory
liumiaocn:bin liumiao$ ln -s ../cellar/wxpython/3.0.2.0_1/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx wx
liumiaocn:bin liumiao$

确认方式

?
1
2
3
4
5
liumiaocn:~ liumiao$ python -c "import wx; print wx.version"
/usr/local/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/_core.py:16633: userwarning: wxpython/wxwidgets release number mismatch
 warnings.warn("wxpython/wxwidgets release number mismatch")
(3, 0, 2, 0, '')
liumiaocn:~ liumiao$

虽然仍然提示warning信息,但是已经能够正常继续动作了。

安装robotframework-ride

使用pip安装robotframework-ride, 安装命令如下

安装命令:pip install robotframework-ride

启动确认

通过ride.py启动ride,当前版本出现了如下错误信息

?
1
2
3
4
5
liumiaocn:bin liumiao$ ride.py
wrong wxpython version.
you need to install wxpython 2.8.12.1 with unicode support to run ride.
wxpython 2.8.12.1 can be downloaded from http://sourceforge.net/projects/wxpython/files/wxpython/2.8.12.1/
liumiaocn:bin liumiao$

原因确认:经过定位代码中错误出现的位置,确认到如下文件:

?
1
2
3
4
5
6
7
8
liumiaocn:local liumiao$ find . -name '*.py' |xargs grep 'you need to install wxpython'
./lib/python2.7/site-packages/robotide/__init__.py:you need to install wxpython 2.8.12.1 with unicode support to run ride.
liumiaocn:local liumiao$ view ./lib/python2.7/site-packages/robotide/__init__.py
liumiaocn:local liumiao$ grep supported_versions ./lib/python2.7/site-packages/robotide/__init__.py
supported_versions = ["2.8"]
    supported_versions.append("2.9")
  wxversion.select(supported_versions)
liumiaocn:local liumiao$

对应方法1:直接将支持的版本号修改为当前的版本

?
1
2
3
4
5
6
7
liumiaocn:~ liumiao$ diff /usr/local/lib/python2.7/site-packages/robotide/__init__.py /usr/local/lib/python2.7/site-packages/robotide/__init__.py.org
37,38c37
< #supported_versions = ["2.8"]
< supported_versions = ["3.0.2.0"]
---
> supported_versions = ["2.8"]
liumiaocn:~ liumiao$

对应方法2:添加supported_versions

?
1
2
3
4
liumiaocn:~ liumiao$ diff /usr/local/lib/python2.7/site-packages/robotide/__init__.py /usr/local/lib/python2.7/site-packages/robotide/__init__.py.org
44d43
<     supported_versions.append("3.0.2.0")
liumiaocn:~ liumiao$

实际上在如下行添加了对当前版本的支持

?
1
2
3
4
5
6
7
8
try:
  import wxversion
  from wxversion import versionerror
  if sys.platform == 'darwin':
    supported_versions.append("2.9")
    supported_versions.append("3.0.2.0")
  wxversion.select(supported_versions)
  import wx

安装robotframework

使用pip install robotramework进行robotframework的安装

?
1
2
3
4
5
6
7
8
9
10
11
liumiaocn:~ liumiao$ pip install robotframework
collecting robotframework
 downloading https://files.pythonhosted.org/packages/95/b1/4faa12e1950b9fbd00060c112fa6f828c4f3998e9b2f8c570c22db10bc88/robotframework-3.0.4.tar.gz (443kb)
  100% |████████████████████████████████| 450kb 34kb/s
building wheels for collected packages: robotframework
 running setup.py bdist_wheel for robotframework ... done
 stored in directory: /users/liumiao/library/caches/pip/wheels/8a/01/4a/fd9aef57cca0087d0bd5ceba5db39247ef375fdc4df5ebfb59
successfully built robotframework
installing collected packages: robotframework
successfully installed robotframework-3.0.4
liumiaocn:~ liumiao$

启动ride

在命令行输入ride.py并回车,便可启动ride

基于Python在MacOS上安装robotframework-ride

安装pygments

text edit的tab提示需要安装高亮显示用的包pygments

基于Python在MacOS上安装robotframework-ride

使用pip install pygments进行安装

?
1
2
3
4
5
6
7
liumiaocn:~ liumiao$ pip install pygments
collecting pygments
 downloading https://files.pythonhosted.org/packages/02/ee/b6e02dc6529e82b75bb06823ff7d005b141037cb1416b10c6f00fc419dca/pygments-2.2.0-py2.py3-none-any.whl (841kb)
  100% |████████████████████████████████| 849kb 1.9mb/s
installing collected packages: pygments
successfully installed pygments-2.2.0
liumiaocn:~ liumiao$

再次启动ride.py,已经可以正常动作了。

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对服务器之家的支持。如果你想了解更多相关内容请查看下面相关链接

原文链接:https://blog.csdn.net/liumiaocn/article/details/80739206

延伸 · 阅读

精彩推荐