ModuleNotFoundError:没有名为“selenium”的模块,但安装了 selenium

问题描述 投票:0回答:2
import selenium 

退货

ModuleNotFoundError: No module named 'selenium'

但是当我 pip freeze 我看到:

selenium==4.8.2

跑步:

  • spyder 5.4.2
  • 蟒蛇 3.8.10
  • 视窗 11 专业版

已尝试使用 pip 安装/卸载 selenium

跑步

python -m pip install -U selenium
回报: “python”不被识别为内部或外部命令, 可运行的程序或批处理文件。

与 py 相同,而不是 python

可能与环境有关,但在安装 python 后没有设置,所以不确定下载的包的去向与 spyder 从哪里提取包

python windows selenium-webdriver pip spyder
2个回答
0
投票

尝试运行

python3 -m pip install -U selenium
而不是
python -m pip install -U selenium
。原因是您的系统/环境中有 python3 但没有 python2。 此外,如果需要,您可以创建一个别名以在控制台中编写
python3
时使用
python
。请检查此操作方法Windows 命令提示符中的别名


0
投票

尝试使用 pip3 进行安装

pip3 install selenium
© www.soinside.com 2019 - 2024. All rights reserved.