如何使用pip + Jython为Robot Framework安装Selenium2Library?

时间:2015-05-29 13:32:10

标签: selenium-webdriver pip jython robotframework jython-2.7

从版本2.7.0开始,Jython包含了捆绑的pip。只需要在使用它之前运行以下命令来激活它:

jython -m ensurepip

实际上,之后应该可以使用

安装Selenium2Library for Robot Framework
jython -m pip install robotframework-selenium2library

正确?

但是当我这样做时,我收到以下错误:

AttributeError: 'module' object has no attribute 'geteuid'

这是完整的cmd / shell输出:

C:\foldername>jython -m pip install selenium2library
Traceback (most recent call last):
  File "C:\Jython27\Lib\runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "C:\Jython27\Lib\runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "C:\Jython27\Lib\runpy.py", line 109, in _get_module_details
    return _get_module_details(pkg_main_name)
  File "C:\Jython27\Lib\runpy.py", line 109, in _get_module_details
    return _get_module_details(pkg_main_name)
  File "C:\Jython27\Lib\runpy.py", line 101, in _get_module_details
    loader = get_loader(mod_name)
  File "C:\Jython27\Lib\pkgutil.py", line 478, in get_loader
    return find_loader(fullname)
  File "C:\Jython27\Lib\pkgutil.py", line 488, in find_loader
    for importer in iter_importers(fullname):
  File "C:\Jython27\Lib\pkgutil.py", line 439, in iter_importers
    __import__(pkg)
  File "C:\Jython27\Lib\site-packages\pip\__init__.py", line 10, in <module>
    from pip.util import get_installed_distributions, get_prog
  File "C:\Jython27\Lib\site-packages\pip\util.py", line 17, in <module>
    from pip.locations import (
  File "C:\Jython27\Lib\site-packages\pip\locations.py", line 109, in <module>
    build_prefix = _get_build_prefix()
  File "C:\Jython27\Lib\site-packages\pip\locations.py", line 90, in _get_build_
prefix
    if file_uid != os.geteuid():
AttributeError: 'module' object has no attribute 'geteuid'

为什么我收到此错误?

BTW:从源代码安装很好用

jython setup.py install

添加信息:我在Windows 8.1 64位上使用Java 1.8,Jython 2.7.0,Robot Framework 2.8.7

1 个答案:

答案 0 :(得分:3)

我在安装Jython 2.7.0后也遇到了这个问题。似乎由于某种原因PIP 1.6(真的很旧)被使用(导致该错误),这个步骤应该解决它:

  1. 删除文件夹%TEMP%\ pip_build_ [username]
  2. 运行jython -m pip install -U pip to upgrade pip以卸载PIP并将其升级到7.x
  3. 希望这有帮助!