Python: 执行代码时出现 Traceback 错误

Python: Getting Traceback error while executing the code

当我 运行 代码为 bzt test.yml 时,我收到了错误。 在它工作正常之前。

C:\etc\tmp\my-test>more test.yml
---
execution:
   concurrency: 50
   hold-for: 2m30s
   ramp-up: 1m
   scenario:
      requests:
         - url: http://server12:12012/

    C:\etc\tmp\my-test>bzt test.yml
        Traceback (most recent call last):
          File "C:\Python27\Scripts\bzt-script.py", line 9, in <module>
            load_entry_point('bzt==1.6.7', 'console_scripts', 'bzt')()
          File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 564, in load_entry_point
            return get_distribution(dist).load_entry_point(group, name)
          File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2621, in load_entry_point
            return ep.load()
          File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2281, in load
            return self.resolve()
          File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2287, in resolve
            module = __import__(self.module_name, fromlist=['__name__'], level=0)
          File "c:\python27\lib\site-packages\bzt\cli.py", line 32, in <module>
            from bzt.engine import Engine, Configuration, ScenarioExecutor
          File "c:\python27\lib\site-packages\bzt\engine.py", line 37, in <module>
            from bzt.six import build_opener, install_opener, urlopen, request, numeric_types, iteritems
          File "c:\python27\lib\site-packages\bzt\six\__init__.py", line 35, in <module>
            import elementtree.ElementTree as etree
        ImportError: No module named elementtree.ElementTree
ImportError: No module named elementtree.ElementTree

你确定它不应该是

import xml.etree.ElementTree as etree

否则请检查您是否安装了此依赖项,或者您当前项目中是否有一个 "elementtree" 文件夹 与导入查找有关。

我觉得 lxml 包裹丢失或损坏了。

解决方法在:

  1. 试用Taurus Installer
  2. 通过 pip 重新安装 lxml and/or bzt 包。

查看:

如果问题仍然存在,请使用 bzt.log 文件内容更新您的问题。