首页 > 解决方案 > ModuleNotFoundError:没有名为“selenium”的模块,jupyter notebooks python 参考

问题描述

我真的只是想用python打开一个网页。我认为问题在于 Jupyter 笔记本使用的 python 版本与存储 selenium 的版本不同,但我不确定当我从 Jupyter 笔记本安装 selenium 时这怎么可能。我将在下面提供更多详细信息。

我的示例代码很无聊:

from selenium import webdriver

driver = webdriver.chrome()
driver.get('http://python.org')

这当然给出了标题中的错误。我的操作系统是 Linux,发行版是 Linux Mint。终端说我有 Python 2.7.17,pip 是 9.0.1 版(python 2.7)。

尝试通过运行安装 selenium

!pip2 install selenium

在路径 /home/frogsnakeman/.local/lib/python2.7/site-packages 中给出“selenium”和“selenium-3.141.0 dist-info”文件夹(我的用户是 frogsnakeman :P)

然而,输入

from platform import python_version
print(python_version())

返回 3.6.9。

标签: pythonseleniumselenium-webdriverjupyter-notebook

解决方案


要检查您安装的库,您可以使用pip freeze

要检查您是否可以使用两个以上的 python 版本,wich python并且在键入选项卡之后,所有可用版本都会为您显示。


推荐阅读