0

我在 python 中编写了一个自定义库,它导入了一个名为“asammdf”的包。但是,当我在机器人代码中导入我的自定义库时,它在 python 中导入“asammdf”时显示错误。它说:“文件 *.robot 中的错误。导入测试库 *.py 失败。导入错误:DLL 加载失败:找不到指定的模块。”

“asammdf”包在它在执行期间提到的 PYTHONPATH 之一中可用。

有人可以帮我做这件事并让我知道,我做错了什么吗?我的python文件(trialRobot.py):

import asammdf
...
...
...

我的机器人文件(TC1.robot):

*** Settings ***
Library trialRobot.py

*** Test Cases ***
TC1
   DO THIS
   DO THAT

它显示的错误是:

[ ERROR ] Error in file 'G:\AutomationRobotFramework\RobotAutomationFramework\TC1.robot': Im
porting test library 'G:\AutomationRobotFramework\RobotAutomationFramework\trialRobot.py' fa
iled: ImportError: DLL load failed: The specified module could not be found.
Traceback (most recent call last):
  File "G:\AutomationRobotFramework\RobotAutomationFramework\trialRobot.py", line 1, in <mod
ule>
    import asammdf
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\__init__.py", line 15, in
 <module>
    from .blocks.mdf_v2 import MDF2
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\blocks\mdf_v2.py", line 4
, in <module>
    from .mdf_v3 import MDF3
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\blocks\mdf_v3.py", line 4
4, in <module>
    from ..signal import Signal
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\signal.py", line 9, in <m
odule>
    from .blocks.utils import MdfException, extract_cncomment_xml, SignalSource
  File "g:\automationrobotframework\venv\lib\site-packages\asammdf\blocks\utils.py", line 27
, in <module>
    from cchardet import detect
  File "g:\automationrobotframework\venv\lib\site-packages\cchardet\__init__.py", line 1, in
 <module>
    from cchardet import _cchardet

PYTHONPATH:
  G:\AutomationRobotFramework\venv\Scripts\robot.exe
  C:\Program Files\Python37\python37.zip
  C:\Program Files\Python37\DLLs
  C:\Program Files\Python37\lib
  C:\Program Files\Python37
  g:\automationrobotframework\venv
  g:\automationrobotframework\venv\lib\site-packages
  g:\automationrobotframework\venv\lib\site-packages\pip-19.0.3-py3.7.egg

但是, asammdf 包是使用 pip 安装在 python 中的,没有任何名称或位置冲突。它只安装一次,并且在默认情况下安装 pip 的文件夹中。提前致谢。

4

2 回答 2

0

您需要提供 example.py 文件的绝对路径或相对路径。

很喜欢,

*** Settings ***
Library C:/SomeFolder/example.py

或者

*** Settings ***
Library ../folder/example.py
于 2020-04-09T16:37:14.123 回答
0

您需要安装 cchardet 2.1.5

于 2020-04-09T19:28:32.670 回答