导入错误:没有名为 Selenium2Library 的模块

导入错误:没有名为 Selenium2Library 的模块

我对 Robot Framework 还很陌生,需要一些帮助。

我正在使用 Ubuntu 14。并且我按照以下步骤安装了 Robot:

# Python package management tool pip.
sudo apt-get install python2.7-dev
sudo apt-get install python-setuptools
sudo apt-get install python-pip

# wxPython
sudo apt-get install python-wxgtk2.8
sudo apt-get install python-wxversion

# Setting up actual robotframework + ide + selenium library.
sudo pip install robotframework
sudo pip install robotframework-ride
sudo pip install robotframework-seleniumlibrary

我使用 python ride.py(或sudo python ride.py)并且框架运行。还运行了一些简单的测试。但在其他情况下,我会因为库依赖关系而收到错误,例如:(ImportError: No module named Selenium2Library还有其他)

当我安装库(使用sudo -H pip install robotframework-selenium2library)时,我得到以下信息:

Requirement already satisfied (use --upgrade to upgrade): robotframework-selenium2library in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): decorator>=3.3.2 in /usr/local/lib/python2.7/dist-packages (from robotframework-selenium2library)
Requirement already satisfied (use --upgrade to upgrade): selenium>=2.32.0 in /usr/local/lib/python2.7/dist-packages (from robotframework-selenium2library)
Requirement already satisfied (use --upgrade to upgrade): robotframework>=2.6.0 in /usr/local/lib/python2.7/dist-packages (from robotframework-selenium2library)
Requirement already satisfied (use --upgrade to upgrade): docutils>=0.8.1 in /usr/local/lib/python2.7/dist-packages (from robotframework-selenium2library)
Cleaning up...

因此,看起来这些库已安装,但看不到。您认为这是权限问题吗?您认为它们应该安装在特定目录中,以便可以访问它们吗?

欢迎提出任何想法!提前谢谢 :)

答案1

我必须为自己的用户启用该库。标志:--user,对我来说很管用。

sudo pip uninstall robotframework-selenium2library
pip install --user robotframework-selenium2library

但如果不先卸载它,我就会收到requirement already satisfied消息。

相关内容