Python: 未检测到已安装的 selenium 包

Python: installed selenium package not detected

我正在使用 Anaconda python distribution and would like to use the selenium 包。不幸的是,发行版中没有包含 selenium,所以我使用推荐的方式安装了它:

pip install -U selenium

发行版 FAQ 说这应该可以正常工作,但是当我尝试使用它时,我得到 python 告诉我它对这个包一无所知。

>>> import selenium
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named selenium

我检查了一下 /usr/local/lib/python2.7/dist-packages 目录中确实有 selenium。如何将我的 python 发行版指向此以便我可以使用该软件包?

根据 this 问题中评论的建议,我使用随发行版安装的 pip 安装了 Selenium。

~/anaconda/bin/pip install -U selenium

我以前不知道这个,但它似乎奏效了。

尝试:

conda install -c metaperl selenium=2.40.0

以下对我有效:

conda install -c conda-forge selenium

详情请查看the Selenium page in Anaconda website