我在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
不会引发此错误。