Robot Rramework 环境搭建

python 3.10 安装过程失败

依赖关系: robotframework -> pip install robotframework-ride -> xwPython
原因可能是xwPthon 库不支持py3.10

安装步骤

1.pip install robotframework==3.1 成功
2.pip install robotframework-ride 失败,报错如下

C:\windows\system32>pip install robotframework-ride
Collecting robotframework-ride
  Using cached robotframework-ride-1.7.4.2.tar.gz (846 kB)
Collecting wxPython<=4.0.7.post2
  Using cached wxPython-4.0.7.post2.tar.gz (68.9 MB)
Collecting PyPubSub
  Using cached Pypubsub-4.0.3-py3-none-any.whl (61 kB)
Collecting Pygments
  Using cached Pygments-2.11.1-py3-none-any.whl (1.1 MB)
Collecting Pywin32
  Using cached pywin32-303-cp310-cp310-win_amd64.whl (9.2 MB)
Requirement already saisfid: pillow in e:\code_tool\python\lib\site-packages (from wxPython<=4.0.7.post2->robotframework-ride) (9.0.0)
Requirement already satisfied: six in e:\code_tool\python\lib\site-packages (from wxPython<=4.0.7.post2->robotframework-ride) (1.16.0)
Requirement already satisfied: numpy in e:\code_tool\python\lib\site-packages (from wxPython<=4.0.7.post2->robotframework-ride) (1.22.0)
Using legacy 'setup.py install' for robotframework-ride, since package 'wheel' is not installed.
Using legacy 'setup.py install' for wxPython, since package 'wheel' is not installed.
Installing collected packages: wxPython, Pywin32, PyPubSub, Pygments, robotframework-ride
    Running setup.py install for wxPython ... error
    ERROR: Command errored out with exit status 1:
     command: 'E:\code_tool\python\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\86158\\AppData\\Local\\Temp\\pip-install-74zqnuxx\\wxpython_8e8a9e908dea47f9b15710684e05ee72\\setup.py'"'"'; __file__='"'"'C:\\Users\\86158\\AppData\\Local\\Temp\\pip-install-74zqnuxx\\wxpython_8e8a9e908dea47f9b15710684e05ee72\\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\86158\AppData\Local\Temp\pip-record-8debmi4f\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\code_tool\python\Include\wxPython'
         cwd: C:\Users\86158\AppData\Local\Temp\pip-install-74zqnuxx\wxpython_8e8a9e908dea47f9b15710684e05ee72\
    Complete output (41 lines):
    E:\code_tool\python\lib\site-packages\setuptools\dist.py:717: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
      warnings.warn(
    E:\code_tool\python\lib\site-packages\setuptools\dist.py:294: DistDeprecationWarning: use_2to3 is ignored.
      warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
    running install
    running build
    C:\Users\86158\AppData\Local\Temp\pip-install-74zqnuxx\wxpython_8e8a9e908dea47f9b15710684e05ee72\build.py:41: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
      from distutils.dep_util import newer, newer_group
    Will build using: "E:\code_tool\python\python.exe"
    3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]
    Python's architecture is 64bit
    cfg.VERSION: 4.0.7.post2

    Running command: build
    Running command: build_wx
    Command '"E:\code_tool\python\python.exe" -c "import distutils.msvc9compiler as msvc; mc = msvc.MSVCCompiler(); mc.initialize(); print(mc.cc)"' failed with exit code 1.
    <string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

    Traceback (most recent call last):

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

      File "E:\code_tool\python\lib\distutils\msvc9compiler.py", line 371, in initialize

        vc_env = query_vcvarsall(VERSION, plat_spec)

      File "E:\code_tool\python\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.82s)
    Finished command: build (0.82s)
    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.

    "E:\code_tool\python\python.exe" -u build.py build
    Command '"E:\code_tool\python\python.exe" -u build.py build' failed with exit code 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'E:\code_tool\python\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\86158\\AppData\\Local\\Temp\\pip-install-74zqnuxx\\wxpython_8e8a9e908dea47f9b15710684e05ee72\\setup.py'"'"'; __file__='"'"'C:\\Users\\86158\\AppData\\Local\\Temp\\pip-install-74zqnuxx\\wxpython_8e8a9e908dea47f9b15710684e05ee72\\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\86158\AppData\Local\Temp\pip-record-8debmi4f\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\code_tool\python\Include\wxPython' Check the logs for full command output.
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the 'E:\code_tool\python\python.exe -m pip install --upgrade pip' command.

3.采用源码安装RIDE, 方式:F:\soft\RIDE-2.0b1> python setup.py install
log:

running install_egg_info
running egg_info
creating src\robotframework_ride.egg-info
writing src\robotframework_ride.egg-info\PKG-INFO
writing dependency_links to src\robotframework_ride.egg-info\dependency_links.txt
writing requirements to src\robotframework_ride.egg-info\requires.txt
writing top-level names to src\robotframework_ride.egg-info\top_level.txt
writing manifest file 'src\robotframework_ride.egg-info\SOURCES.txt'
reading manifest file 'src\robotframework_ride.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE.txt'
adding license file 'AUTHORS.txt'
writing manifest file 'src\robotframework_ride.egg-info\SOURCES.txt'
Copying src\robotframework_ride.egg-info to E:\code_tool\python\Lib\site-packages\robotframework_ride-2.0b1-py3.10.egg-info
running install_scripts
copying build\scripts-3.10\ride.py -> E:\code_tool\python\Scripts
copying build\scripts-3.10\ride_postinstall.py -> E:\code_tool\python\Scripts
Creating Desktop Shortcut to RIDE...
No wxPython installation detected!
Please ensure that you have wxPython installed before running RIDE. You can obtain wxPython from https://wxpython.org/pages/downloads/
or pip install wxPython
  1. pip install wxPython
Collecting wxPython
  Downloading wxPython-4.1.1.tar.gz (66.0 MB)
     |████████████████████████████████| 66.0 MB 58 kB/s
Requirement already satisfied: pillow in e:\code_tool\python\lib\site-packages (from wxPython) (9.0.0)
Requirement already satisfied: six in e:\code_tool\python\lib\site-packages (from wxPython) (1.16.0)
Requirement already satisfied: numpy in e:\code_tool\python\lib\site-packages (from wxPython) (1.22.0)
Using legacy 'setup.py install' for wxPython, since package 'wheel' is not installed.
Installing collected packages: wxPython
    Running setup.py install for wxPython ... error
    ERROR: Command errored out with exit status 1:
     command: 'E:\code_tool\python\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\86158\\AppData\\Local\\Temp\\pip-install-odjbrpa3\\wxpython_bb02dc3d3468493cb945df98984421b8\\setup.py'"'"'; __file__='"'"'C:\\Users\\86158\\AppData\\Local\\Temp\\pip-install-odjbrpa3\\wxpython_bb02dc3d3468493cb945df98984421b8\\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\86158\AppData\Local\Temp\pip-record-g7oq_jl7\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\code_tool\python\Include\wxPython'
         cwd: C:\Users\86158\AppData\Local\Temp\pip-install-odjbrpa3\wxpython_bb02dc3d3468493cb945df98984421b8\
    Complete output (51 lines):
    E:\code_tool\python\lib\site-packages\setuptools\dist.py:717: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
      warnings.warn(
    E:\code_tool\python\lib\site-packages\setuptools\dist.py:294: DistDeprecationWarning: use_2to3 is ignored.
      warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
    running install
    running build
    C:\Users\86158\AppData\Local\Temp\pip-install-odjbrpa3\wxpython_bb02dc3d3468493cb945df98984421b8\build.py:41: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
      from distutils.dep_util import newer, newer_group
    Will build using: "E:\code_tool\python\python.exe"
    3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]
    Python's architecture is 64bit
    cfg.VERSION: 4.1.1

    Running command: build
    Running command: build_wx
    Command '"E:\code_tool\python\python.exe" -c "import setuptools, 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 "E:\code_tool\python\lib\distutils\msvc9compiler.py", line 371, in initialize

        vc_env = query_vcvarsall(VERSION, plat_spec)

      File "E:\code_tool\python\lib\site-packages\setuptools\msvc.py", line 140, in msvc9_query_vcvarsall

        return EnvironmentInfo(arch, ver).return_env()

      File "E:\code_tool\python\lib\site-packages\setuptools\msvc.py", line 1740, in return_env

        [self.VCIncludes,

      File "E:\code_tool\python\lib\site-packages\setuptools\msvc.py", line 1282, in VCIncludes

        return [join(self.si.VCInstallDir, 'Include'),

      File "E:\code_tool\python\lib\site-packages\setuptools\msvc.py", line 840, in VCInstallDir

        raise distutils.errors.DistutilsPlatformError(msg)

    distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    Finished command: build_wx (0.231s)
    Finished command: build (0.231s)
    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.

    "E:\code_tool\python\python.exe" -u build.py build
    Command '"E:\code_tool\python\python.exe" -u build.py build' failed with exit code 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'E:\code_tool\python\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\86158\\AppData\\Local\\Temp\\pip-install-odjbrpa3\\wxpython_bb02dc3d3468493cb945df98984421b8\\setup.py'"'"'; __file__='"'"'C:\\Users\\86158\\AppData\\Local\\Temp\\pip-install-odjbrpa3\\wxpython_bb02dc3d3468493cb945df98984421b8\\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\86158\AppData\Local\Temp\pip-record-g7oq_jl7\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\code_tool\python\Include\wxPython' Check the logs for full command output.

至此放弃,换python3.8装

python 3.8 安装成功

安装过程

  1. pip install robotframework
  2. pip install robotframework-ride
  3. 会自动提示创建桌面快捷方式,点击确定即可

  1. 至此已安装完毕

打开遇到的问题

  1. 双击桌面快捷方式没有反应
  2. %pythonhome%/Scripts/ 下执行python ride.py报错:
Traceback (most recent call last):
  File "E:\code_tool\python3.8\lib\site-packages\robotide\application\application.py", line 58, in OnInit
    self.frame = RideFrame(self, self._controller)
  File "E:\code_tool\python3.8\lib\site-packages\robotide\ui\mainframe.py", line 175, in __init__
    self._init_ui()
  File "E:\code_tool\python3.8\lib\site-packages\robotide\ui\mainframe.py", line 279, in _init_ui
    self.tree = Tree(self, self.actions,
  File "E:\code_tool\python3.8\lib\site-packages\robotide\ui\tree.py", line 86, in __init__
    self._images = TreeImageList()
  File "E:\code_tool\python3.8\lib\site-packages\robotide\ui\images.py", line 42, in __init__
    TestCaseController: _TreeImage(self, 'robot.png'),
  File "E:\code_tool\python3.8\lib\site-packages\robotide\ui\images.py", line 80, in __init__
    self.normal = self._get_image(image_list, normal)
  File "E:\code_tool\python3.8\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

解决办法:
在 Python\Python38\Lib\site-packages\robotide\application\application.py这个文件中加入

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

加入的位置:

之后使用ride启动命令,桌面快捷方式也可以启动
python ride.py

上个图,太难了

安装总结:

我的版本信息如下:

Python 版本不要用太新的版本,不然太多坑了

  1. robot framework 官网:https://robotframework.org/?tab=tools#resources
  2. 如果pip install robotframework-ride 失败,可以用
    ride 源码安装:https://github.com/robotframework/RIDE/releases
  3. 一般pip insttall robotframework-ride 就会下载所依赖的xwPython,但也可以单独下载
    官方下载地址:https://pypi.org/project/wxPython/#files
  4. 下载完毕后运行不起来参考:https://www.freesion.com/article/69041188706/

测试用例 Edit 面板打不开

更新ride版本

pip install -U https://github.com/robotframework/RIDE/archive/master.zip

posted @ 2022-01-04 21:24  chuangzhou  阅读(632)  评论(0编辑  收藏  举报