python3安装robotframework时遇到的版本适配的坑

1安装

在网上百度的,碰到了一些坑。

基本安装比较简单,都是使用pip install进行应用安装。
但是其中涉及的版本问题很坑。

我遇到的问题是,使用了当前(2021-04-30)最新的python
版本为3.9.4

然后使用
pip install robotframework-ride
命令,进行robotframework的安装。
安装默认使用的robotframework-ride版本为1.7.4.2,
适配wxPython<=4.0.7版本
但是当安装wxPython时,由于4.0.7之前版本,没有适配py39版本的whl文件,所以一直存在如下报错:

    Running setup.py install for wxpython ... error
    ERROR: Command errored out with exit status 1:
     command: 'd:\programfiles\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\lixiang\\AppData\\Local\\Temp\\pip-install-x8x2_mh9\\wxpython_4df37eab90754ac789782b9759972ea8\\setup.py'"'"'; __file__='"'"'C:\\Users\\lixiang\\AppData\\Local\\Temp\\pip-install-x8x2_mh9\\wxpython_4df37eab90754ac789782b9759972ea8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\lixiang\AppData\Local\Temp\pip-record-xzx8avr2\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\programfiles\python\python39\Include\wxpython'
         cwd: C:\Users\lixiang\AppData\Local\Temp\pip-install-x8x2_mh9\wxpython_4df37eab90754ac789782b9759972ea8\
    Complete output (33 lines):
    running install
    running build
    Will build using: "d:\programfiles\python\python39\python.exe"
    3.9.4 (tags/v3.9.4:1f2e308, Apr  6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)]
    Python's architecture is 64bit
    cfg.VERSION: 4.0.7

    Running command: build
    Running command: build_wx
    Command '"d:\programfiles\python\python39\python.exe" -c "import distutils.msvc9compiler as msvc; mc = msvc.MSVCCompiler(); mc.initialize(); print(mc.cc)"' failed with exit code 1.
    Traceback (most recent call last):

      File "<string>", line 1, in <module>

      File "d:\programfiles\python\python39\lib\distutils\msvc9compiler.py", line 371, in initialize

        vc_env = query_vcvarsall(VERSION, plat_spec)

      File "d:\programfiles\python\python39\lib\distutils\msvc9compiler.py", line 260, in query_vcvarsall

        raise DistutilsPlatformError("Unable to find vcvarsall.bat")

    distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat
    Finished command: build_wx (0.47s)
    Finished command: build (0.47s)
    WARNING: Building this way assumes that all generated files have been
    generated already.  If that is not the case then use build.py directly
    to generate the source and perform the build stage.  You can use
    --skip-build with the bdist_* or install commands to avoid this
    message and the wxWidgets and Phoenix build steps in the future.

    "d:\programfiles\python\python39\python.exe" -u build.py build
    Command '"d:\programfiles\python\python39\python.exe" -u build.py build' failed with exit code 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\programfiles\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\lixiang\\AppData\\Local\\Temp\\pip-install-x8x2_mh9\\wxpython_4df37eab90754ac789782b9759972ea8\\setup.py'"'"'; __file__='"'"'C:\\Users\\lixiang\\AppData\\Local\\Temp\\pip-install-x8x2_mh9\\wxpython_4df37eab90754ac789782b9759972ea8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\lixiang\AppData\Local\Temp\pip-record-xzx8avr2\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\programfiles\python\python39\Include\wxpython' Check the logs for full command output.

D:\ProgramFiles\Python\Python39>

其中重点关注“Unable to find vcvarsall.bat”报错,该报错原因通过百度,发现是未找到whl文件,导致报错。
然后,想通过如下网址自己下载whl文件时,发现针对window-x64有多个版本的whl,其中命名均由xxxcpxxx字样,且该字样有cp37、cp38,但是没有cp39。
https://pypi.org/project/wxPython/4.0.7/#files
之后,查看了py39版本可以安装的4.1.1版本的wxPython,发现存在xxxcp39xxx。所以最终发现,python39版本,无法适配安装wxPython-4.0.7应用。

所以最终下载了一个py38,然后再次执行
pip install robotframework-ride命令,安装成功。

2启动

使用ride.py命令启动时,出现如下报错:

xxx\Python38\Scripts>ride.py
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 0.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 3.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 4.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 5.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 6.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 7.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 19.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 20.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 21.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 22.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 25.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 26.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 27.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 28.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 29.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 30.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 31.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 32.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 33.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 34.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 35.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 36.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 37.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 38.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 39.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 40.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 43.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 44.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 45.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 46.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 47.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 48.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 49.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 50.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 51.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 52.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 53.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 54.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 55.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 56.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 57.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 58.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 59.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 60.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 61.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 62.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 63.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 67.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 68.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 69.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 70.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 71.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 13.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 14.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 0.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 3.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 4.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 5.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 6.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 7.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 19.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 20.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 21.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 22.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 25.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 26.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 27.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 28.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 29.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 30.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 31.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 32.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 33.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 34.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 35.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 36.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 37.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 38.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 39.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 40.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 43.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 44.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 45.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 46.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 47.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 48.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 49.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 50.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 51.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 52.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 53.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 54.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 55.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 56.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 57.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 58.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 59.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 60.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 61.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 62.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 63.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 67.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 68.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 69.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 70.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 71.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 13.
Traceback (most recent call last):
  File "xxx\python38\lib\site-packages\robotide\application\application.py", line 58, in OnInit
    self.frame = RideFrame(self, self._controller)
  File "xxx\python38\lib\site-packages\robotide\ui\mainframe.py", line 175, in __init__
    self._init_ui()
  File "xxx\python38\lib\site-packages\robotide\ui\mainframe.py", line 279, in _init_ui
    self.tree = Tree(self, self.actions,
  File "xxx\python38\lib\site-packages\robotide\ui\tree.py", line 86, in __init__
    self._images = TreeImageList()
  File "xxx\python38\lib\site-packages\robotide\ui\images.py", line 42, in __init__
    TestCaseController: _TreeImage(self, 'robot.png'),
  File "xxx\python38\lib\site-packages\robotide\ui\images.py", line 80, in __init__
    self.normal = self._get_image(image_list, normal)
  File "xxx\python38\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

xxx\Python38\Scripts>

通过修改报错中
xxx\python38\lib\site-packages\robotide\application\application.py文件中的
self._initial_locale = wx.Locale(wx.LANGUAGE_ENGLISH)
改为:
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)后,
ride可正常打开。
参考:https://blog.csdn.net/wel2014/article/details/104761191/

怀疑还是因为版本问题,导致部分需要的信息不一致,所以需要进行改动适配。

3安装执行案例脚本可能需要的库

参考:https://blog.csdn.net/cindy_jymm/article/details/53765622

1、安装Selenium2Library的依赖库decorator
可通过pip安装:pip install decorator

也可以到如下地址找到安装信息,或下载tar.gz包进行安装https://pypi.org/project/decorator/
下载tar.gz包进行安装,需要解压缩,然后,执行安装命令 python setup.py install,等待安装成功即可

若无法安装可通过豆瓣等国内镜像安装,毕竟外网下载一般会慢些甚至无法下载。
可以参考
https://blog.csdn.net/qq_30754565/article/details/82777253?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&dist_request_id=1619765231558_68139&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control

2、安装Selenium
Selenium是Selenium2Library的底层库
pip install selenium

3、安装库Selenium2Library
该库用作界面ui操作
pip install robotframework-selenium2library

4、安装HttpLibrary
该库主要应用于发送和接受http请求,一般用作接口测试
pip install –upgrade robotframework-httplibrary

5、安装,requests,requestsLibrary库
主要用于接口测试
requestsLibrary库基于requests,所以需要先安装requests,再安装requestsLibrary
注:直接安装requestsLibrary会自动下载引入依赖
pip install robotframework-requests
国内镜像方式
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple robotframework-requests

6、安装pymysql库
该库为DataBase的依赖库
pip install PyMySQL

7、安装DataBase Library库
功能:提供链接数据库的关键字
pip install robotframework-databaselibrary

8、安装solr库
pip install solrpy

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值