【问题标题】:Robotframework - "failed: ImportError: No module named requests"Robotframework - “失败:ImportError: No module named requests”
【发布时间】:2018-05-24 18:49:56
【问题描述】:

安装此模块时出现“No module named requests”错误(错误后有更多详细信息):

[ ERROR ] Error in file '/Users/adikeller/Applications/GIT/BeAm/Beacon_4.10/STABILITY/beacon_stability_random_beacon_types.txt': Importing test library 'BeAm.beacon.tests.BeaconTesting' failed: ImportError: No module named requests
Traceback (most recent call last):
  File "/Users/adikeller/Applications/GIT/BeAm/BeAm/beacon/tests.py", line 5, in <module>
    from BeAm.beacon.counters import BeaconCounter
  File "/Users/adikeller/Applications/GIT/BeAm/BeAm/beacon/counters.py", line 1, in <module>
    import requests
PYTHONPATH:
  /Users/adikeller/vevn/bin
  /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
  /Users/adikeller/Applications/GIT/BeAm
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
  /Library/Python/2.7/site-packages
  /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
  /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC

我已经做过的事情:

  1. 将工作目录添加到 PYTHONPATH: 导出 PYTHONPATH=$PYTHONPATH:/Users/adikeller/Applications/GIT/BeAm
  2. 安装的“请求”模块: sudo pip 安装请求
  3. 点冻结: ... 请求==0.0.22 请求==2.18.3 机器人==20071211 机器人框架==3.0.2 机器人框架-数据库库==0.8.1 机器人框架-DiffLibrary2==0.0.2.dev0 机器人框架-httplibrary==0.4.2 机器人框架-pycurllibrary==0.9.5 机器人框架-rammbock==0.4.0.1 机器人框架请求==0.4.5 机器人框架骑==1.5.2.1 机器人框架-selenium2library==1.7.4 机器人框架-sshlibrary==2.1.2 ...

附加信息:

  1. 我使用的是 MacBook macOS Sierra (V.10.12.6)
  2. 我在 virtualenv 中运行,我在其中,所有模块都安装在那里。
  3. 我位于运行文件夹中: /Users/adikeller/Applications/GIT/BeAm
  4. 运行命令行:
    pybot Beacon_4.10/STABILITY/beacon_stability_random_beacon_types.txt

beacon_stability_random_beacon_types.txt:

*** Settings ***
Force Tags        Critical    template    Conf=3    isTor=0    isSanity=0    headless    rcmd
Library           BeAm.beacon.tests.BeaconTesting    WITH NAME    BeaconTesting
Library           Collections
Library           BeAm.beacon.stability_and_stress_tests
Library           BeAm.beacon.tests
Resource          ../../BeAm/beacon/settings.txt

*** Test Cases ***
Create Test Object
    [Tags]    must
    ${TEST} =    BeaconTesting.Get Beacon Test    3
    Set Suite Variable    ${TEST}    ${TEST}

【问题讨论】:

    标签: python robotframework


    【解决方案1】:

    请先尝试安装请求库,然后重试

    $ sudo pip install requests
    

    【讨论】:

    • 谢谢,我已经尝试过了(如上面第 2 点所述),它没有解决我的问题。
    • 由于某种原因,模块 counters.py 没有找到“请求”:File "/Users/adikeller/Applications/GIT/BeAm/BeAm/beacon/counters.py", line 1, in &lt;module&gt; import requests 检查 PYTHONPATH 上的修改代码。
    • 嗨,我注意到它只有在我将“--pythonpath /Users/adikeller/Applications/GIT/BeAm”添加到运行命令行时才有效,这意味着robotframework不引用PYTHONPATH参数(它已经包含此路径)。有什么建议为什么 robotsframework 不引用 PYTHONPATH?
    猜你喜欢
    • 2017-03-30
    • 1970-01-01
    • 1970-01-01
    • 2015-09-10
    • 1970-01-01
    • 2012-08-12
    • 2011-10-19
    • 2018-01-19
    • 1970-01-01
    相关资源
    最近更新 更多