无法导入模块"Selenium"



我已经用 pip install selenium成功安装了硒。

我在pycharm上工作,只运行python,我正在使用Windows。

进行import selenium后,我期望它会成功导入硒。

相反,我得到了这个结果:

ModuleNotFoundError: No module named 'selenium'

执行pip install selenium时,您正在为全局Python安装安装selenium。但是用Pycharm创建的项目将默认使用其自己的虚拟环境。

您需要将selenium安装到virtualenv您的项目正在使用。
可以从pycharm中轻松完成:

> File (from menu bar)
> Settings
> Project: projectname
> Project interpreter
> click + and search for package
> Install packge

带有图像的更详细说明:https://www.jetbrains.com/help/pycharm/installing-uninstalling-uninstalling-uninstalling-and-unprading-packages.html

最新更新