自动化工具 python3.8 环境下安装 robot framework 遇到的问题及解决 (别看了,python3.8 能安装,但是启动之后 edit 页面空白了,我退回了 3.7.5....)

滑滑鸡蛋 · 2020年04月29日 · 最后由 BestWei 回复于 2021年03月18日 · 6764 次阅读

突然想起 robot framework 终于支持 python3 了,想着不是特别忙,可以试一下装起来!万万没想到就踩进了一个深坑!以此记录下我犯的那些乱七八糟的错!✍
此篇纯粹碎碎念和吐槽,非技术分享~

首先找了下网上的教程一顿操作,但网上基本上都是 python3.7 或者 3.6 的环境,而本秃头女孩用的 3.8,此刻我就开始慌了......这个版本问题我真是慌得不行,差一丢丢就疯狂报错,事实证明,我的担心是对的🙄 因为版本不对安装不上,我陷入了换版本的困境........先贴一下现在的版本情况👇 太难了 55555😭
python3.8

安装过程就不多说了,反正就是很心酸,以下是安装步骤:
1、安装 python3.8
2、在线安装 robotframework:pip install robotframework
3、在线安装 Pypubsub:Pypubsub==3.3.0 (这玩意别装太高的版本,亲测会有问题😭 哭,至少目前我用这个版本没啥问题....)
4、在线安装 wxPython:wxPython==4.0.7 (这个版本不能太低......太低不支持 python3.8,太高也会报错....爆哭😭 ,然后就找了个版本不高,又支持 3.8 的,就是你了!)
5、在线安装 robotframework-ride:pip install robotframework-ride==1.7.4.1 (这个才是最崩溃的,我本来直接在线安装,然后就安装了最新版 1.7.4.2,结果死活装不上,一直报错,我还以为我网不好,结果仔细一看,不对,这个熟悉的报错,又是版本问题???哭辽,我又去看官方对应的版本,结果人家没说明....好吧,手动降一级试试,终于装上了!!!👏 莫急,装好了也还是会有问题的)
6、安装 appiumlibrary:pip install robotframework-appiumlibrary
7、安装 selenium2library:pip install robotframework-selenium2library
8、把对应版本的【chromedriver.exe】放到 python3 的目录下

安装终于结束了,我以为我能愉快的打开我熟悉的小格子界面,愉快的双击图标,没反应......然后试试 win+R+ride.py,直接找到我 python2.7 的路径下边去了????🙃 ,我还不放弃,找到 python 路径下的 scripts 下的 ride.py 执行 “python ride.py”,又报错了........👇

Traceback (most recent call last):
File “d:\program files (x86)\python\lib\site-packages\robotide\application\application.py”, line 58, in OnInit
self.frame = RideFrame(self, self._controller)
File “d:\program files (x86)\python\lib\site-packages\robotide\ui\mainframe.py”, line 175, in init
self._init_ui()
File “d:\program files (x86)\python\lib\site-packages\robotide\ui\mainframe.py”, line 279, in _init_ui
self.tree = Tree(self, self.actions,
File “d:\program files (x86)\python\lib\site-packages\robotide\ui\tree.py”, line 86, in init
self._images = TreeImageList()
File “d:\program files (x86)\python\lib\site-packages\robotide\ui\images.py”, line 42, in init
TestCaseController: _TreeImage(self, ‘robot.png’),
File “d:\program files (x86)\python\lib\site-packages\robotide\ui\images.py”, line 80, in init
self.normal = self._get_image(image_list, normal)
File “d:\program files (x86)\python\lib\site-packages\robotide\ui\images.py”, line 91, in _get_image
img = wx.Image(path, wx.BITMAP_TYPE_PNG).ConvertToBitmap()
wx._core.wxAssertionError: C++ assertion “strcmp(setlocale(LC_ALL, NULL), “C”) == 0” failed at …\src\common\intl.cpp(1579) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.
Things are going to break, please only change locale by creating wxLocale objects to avoid this!
OnInit returned false, exiting…
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion “GetEventHandler() == this” failed at …\src\common\wincmn.cpp(478) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

好吧,又继续改,把修改 application.py 中 self._initial_locale = wx.Locale(wx.LANGUAGE_ENGLISH) 改为:

self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)

问题是我还报错...🙃

Traceback (most recent call last):
  File "D:\Applications\python3.8.0\lib\site-packages\robotide\__init__.py", line 82, in main
    _run(inpath, not noupdatecheck, debug_console)
  File "D:\Applications\python3.8.0\lib\site-packages\robotide\__init__.py", line 101, in _run
    from robotide.application import RIDE
  File "D:\Applications\python3.8.0\lib\site-packages\robotide\application\__init__.py", line 16, in <module>
    from .application import RIDE, Project
  File "D:\Applications\python3.8.0\lib\site-packages\robotide\application\application.py", line 50
    self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
                                               ^
TabError: inconsistent use of tabs and spaces in indentation


Use --help to get usage information.

缩进问题???我就是担心空格缩进的问题,直接复制的源码进行的修改,实在是想不通,小脑瓜灵机一现,对比了下边的源码,呵呵呵我改的内容是两个 tab,源码是空格还是啥🙃 ,一定要注意前边和后边的空格和缩进啊啊啊啊啊啊!!!重新用源码的格式粘贴过去,就可以打开了!(简单粗暴的方式就是直接 copy 下边肯定没问题的代码的空格或者缩进)

真开心,终于解决了这个问题😭 而且我的桌面图标也可以双击打开了哈哈哈哈哈哈,图标真可爱,新的页面真好看哈哈哈哈哈哈!炫耀!

----------------------------------------我是无情的分割线----------------------------------
我发现的我 ride 虽然打开了,但是我的小格子没有了😩 还有好几个库没装....继续努力!!!

----------------------------------------补充内容---------------------------
1、ExcelLibrary 没有对应的可安装版本,在线安装时会报错

ERROR: Could not find a version that satisfies the requirement robotframework-excellibrar (from versions: none)
ERROR: No matching distribution found for robotframework-excellibrar

2、昨天遇到的 edit 页面空白,百度了一大圈,说 3.8 不兼容......简直无情.....python 版本回退到 3.7.5
附上当前版本

共收到 19 条回复 时间 点赞

支持一下,我们还是用 py2.7 配的 RF

18楼 已删除
仅楼主可见
Felix 回复

RF 用的 2.7,平时要写个代码啥的又是 3.8,环境有时候冲突起来真的太麻烦了,干脆同意好了哈哈哈哈哈

zhouhuiyin 回复

冲冲冲!

我们都是直接在 pycharm 写用例代码,不存在 3.0 版本不支持的烦恼

Jerry li 回复

RF 上手快啊,速度也快,能让团队其他人更快的适应并上手

滑滑鸡蛋 回复

你说的是 ride 吧
我们也是用 rf ,只不过是直接在 pycharm 里写用例,所以 Python 3.0 都是支持的

Jerry li 回复

你这么一说我好像想起来了这么回事,之前有看到过说在 pycharm 里写用例,感谢提醒!

推荐还是 3.6,个人感觉 3.6.4-3.6.8 的版本兼容性较好.
我主要是 tf,pytorch,caffe,tvm,opencv 等等的兼容.

rf 用的不多
不过既然都 python3 了,为什么还要用 ride 呢。我们这 rf 框架里的 case 都是直接编辑器写的,本地环境 python3.8 也没出现过什么问题

你好,我想问下我使用 3.7 的也是这个问题,但是我不知道怎么改额 ,求指点哈

学东 回复

我的 python 版本是 3.7.5,你看看是不是你的 ride 版本不匹配,ride 版本过高了

滑滑鸡蛋 回复

这,,,对应要是版本的呢? 我的 python 是 3.7.3,ride 是 1.7.4.2

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/application/application.py", line 62, in OnInit
self.plugin_loader.enable_plugins()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/application/pluginloader.py", line 43, in enable_plugins
p.enable_on_startup()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/application/pluginconnector.py", line 52, in enable_on_startup
self.enable()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/application/pluginconnector.py", line 57, in enable
self._plugin.enable()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/recentfiles/recentfiles.py", line 44, in enable
self._add_recent_files_to_menu()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/recentfiles/recentfiles.py", line 114, in _add_recent_files_to_menu
self.register_action(action)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/pluginapi/plugin.py", line 204, in register_action
action = self.
_frame.actions.register_action(action_info)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/ui/mainframe.py", line 751, in register_action
self._menubar.register(action)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/ui/actiontriggers.py", line 60, in register
menu.add_menu_item(action)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/ui/actiontriggers.py", line 98, in add_menu_item
menu_item = self._construct_menu_item(action)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/ui/actiontriggers.py", line 107, in _construct_menu_item
menu_item = self._create_menu_item(action)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/ui/actiontriggers.py", line 139, in _create_menu_item
pos = action.get_insertion_index(self.wx_menu)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/action/action.py", line 40, in get_insertion_index
return self._insertion_point.get_index(menu)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/action/actioninfo.py", line 286, in get_index
index = self._find_position_in_menu(menu)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/action/actioninfo.py", line 296, in _find_position_in_menu
if self._get_menu_item_name(item).lower() == self._item.lower():
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/robotide/action/actioninfo.py", line 301, in _get_menu_item_name
return self._shortcut_remover.split(item.GetLabel())[0]
AttributeError: 'MenuItem' object has no attribute 'GetLabel'
OnInit returned false, exiting...
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at /Users/robind/projects/bb2/dist-osx-py38/build/ext/wxWidgets/src/common/wincmn.cpp(475) in ~wxWindowBase(): any pushed event handlers must have been removed

请问下这个报错是为啥呀?

你这个应该是安装了最新版本的 wxPython 4.1.0,需要卸载掉,重新安装指定版本 4.0.7.post2, pip3 install wxPython==4.0.7.post2

Traceback (most recent call last):
File "D:\py\lib\site-packages\robotide\application\application.py", line 62, in OnInit
self.plugin_loader.enable_plugins()
File "D:\py\lib\site-packages\robotide\application\pluginloader.py", line 43, in enable_plugins
p.enable_on_startup()
File "D:\py\lib\site-packages\robotide\application\pluginconnector.py", line 52, in enable_on_startup
self.enable()
File "D:\py\lib\site-packages\robotide\application\pluginconnector.py", line 57, in enable
self._plugin.enable()
File "D:\py\lib\site-packages\robotide\recentfiles\recentfiles.py", line 44, in enable
self._add_recent_files_to_menu()
File "D:\py\lib\site-packages\robotide\recentfiles\recentfiles.py", line 114, in _add_recent_files_to_menu
self.register_action(action)
File "D:\py\lib\site-packages\robotide\pluginapi\plugin.py", line 204, in register_action
action = self.
_frame.actions.register_action(action_info)
File "D:\py\lib\site-packages\robotide\ui\mainframe.py", line 751, in register_action
self._menubar.register(action)
File "D:\py\lib\site-packages\robotide\ui\actiontriggers.py", line 60, in register
menu.add_menu_item(action)
File "D:\py\lib\site-packages\robotide\ui\actiontriggers.py", line 98, in add_menu_item
menu_item = self._construct_menu_item(action)
File "D:\py\lib\site-packages\robotide\ui\actiontriggers.py", line 107, in _construct_menu_item
menu_item = self._create_menu_item(action)
File "D:\py\lib\site-packages\robotide\ui\actiontriggers.py", line 139, in _create_menu_item
pos = action.get_insertion_index(self.wx_menu)
File "D:\py\lib\site-packages\robotide\action\action.py", line 40, in get_insertion_index
return self._insertion_point.get_index(menu)
File "D:\py\lib\site-packages\robotide\action\actioninfo.py", line 286, in get_index
index = self._find_position_in_menu(menu)
File "D:\py\lib\site-packages\robotide\action\actioninfo.py", line 296, in _find_position_in_menu
if self._get_menu_item_name(item).lower() == self._item.lower():
File "D:\py\lib\site-packages\robotide\action\actioninfo.py", line 301, in _get_menu_item_name
return self._shortcut_remover.split(item.GetLabel())[0]
AttributeError: 'MenuItem' object has no attribute 'GetLabel'
OnInit returned false, exiting...
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ....\src\common\wincmn.cpp(475) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

请问下我这个报错是为啥呀?我的 python 是 3.7 的,ride 是 1.7 的
跪求大佬回复

Traceback (most recent call last):
File "D:\Python\Python38\lib\site-packages\robotide\application\application.py", line 63, in OnInit
self.plugin_loader.enable_plugins()
File "D:\Python\Python38\lib\site-packages\robotide\application\pluginloader.py", line 43, in enable_plugins
p.enable_on_startup()
File "D:\Python\Python38\lib\site-packages\robotide\application\pluginconnector.py", line 52, in enable_on_startup
self.enable()
File "D:\Python\Python38\lib\site-packages\robotide\application\pluginconnector.py", line 57, in enable
self._plugin.enable()
File "D:\Python\Python38\lib\site-packages\robotide\recentfiles\recentfiles.py", line 44, in enable
self._add_recent_files_to_menu()
File "D:\Python\Python38\lib\site-packages\robotide\recentfiles\recentfiles.py", line 114, in _add_recent_files_to_menu
self.register_action(action)
File "D:\Python\Python38\lib\site-packages\robotide\pluginapi\plugin.py", line 204, in register_action
action = self.
_frame.actions.register_action(action_info)
File "D:\Python\Python38\lib\site-packages\robotide\ui\mainframe.py", line 751, in register_action
self._menubar.register(action)
File "D:\Python\Python38\lib\site-packages\robotide\ui\actiontriggers.py", line 60, in register
menu.add_menu_item(action)
File "D:\Python\Python38\lib\site-packages\robotide\ui\actiontriggers.py", line 98, in add_menu_item
menu_item = self._construct_menu_item(action)
File "D:\Python\Python38\lib\site-packages\robotide\ui\actiontriggers.py", line 107, in _construct_menu_item
menu_item = self._create_menu_item(action)
File "D:\Python\Python38\lib\site-packages\robotide\ui\actiontriggers.py", line 139, in _create_menu_item
pos = action.get_insertion_index(self.wx_menu)
File "D:\Python\Python38\lib\site-packages\robotide\action\action.py", line 40, in get_insertion_index
return self._insertion_point.get_index(menu)
File "D:\Python\Python38\lib\site-packages\robotide\action\actioninfo.py", line 286, in get_index
index = self._find_position_in_menu(menu)
File "D:\Python\Python38\lib\site-packages\robotide\action\actioninfo.py", line 296, in _find_position_in_menu
if self._get_menu_item_name(item).lower() == self._item.lower():
File "D:\Python\Python38\lib\site-packages\robotide\action\actioninfo.py", line 301, in _get_menu_item_name
return self._shortcut_remover.split(item.GetLabel())[0]
AttributeError: 'MenuItem' object has no attribute 'GetLabel'
OnInit returned false, exiting...
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ....\src\common\wincmn.cpp(470) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

同楼上的问题,也是同样的报错,我是 python3.8,求大佬解答。

python3.8 可以安装 beta 版
pip install -U --pre robotframework-ride
安装完成就可以正常打开了

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册