我已经用 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