Selenium已安装但未找到模块

时间:2020-08-06 18:08:49

标签: python python-3.x selenium

我在Ubuntu 18.04 LTS上安装了Python 3.6。我在硒方面遇到问题。我正在这个项目的虚拟环境中,并且尝试运行sudo python3 -m pip install selenium并显示此Requirement already satisfied: selenium in /usr/local/lib/python3.6/dist-packages (3.141.0) Requirement already satisfied: urllib3 in /home/sysadmin/.local/lib/python3.6/site-packages (from selenium) (1.25.3)

当我尝试运行脚本(python3 test-scrape.py)时,我得到了:

Traceback (most recent call last):
File "test-scrape.py", line 1, in <module>
from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'

我还尝试安装sudo apt install python3-selenium

如果已安装,为什么会引发no module错误?

如果我运行sudo pip3 install selenium尝试安装它,我也会得到:

Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'

为什么此命令出现此错误?另一个命令:sudo python3 -m pip install selenium不会引发此错误。

0 个答案:

没有答案