我尝试了几种不同的方式安装Selenium,并使用命令提示符导航到多个不同的文件夹。但是每次安装时,都会得到以下信息:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: selenium in c:\users\(me)\appdata\roaming\python\python38\site-packages (3.141.0)
Requirement already satisfied: urllib3 in c:\users\(me)\appdata\roaming\python\python38\site-packages (from selenium) (1.25.10)
当我在VSCode中尝试基本测试时,我得到了:
<ipython-input-1-8510f5dbbe17> in <module>
----> 1 from selenium import webdriver
2 driver = webdriver.Chrome()
3 driver.get('https://www.nasa.gov')
4 headlines = driver.find_elements_by_class_name("headline")
5 for headline in headlines:
ModuleNotFoundError: No module named 'selenium'
我也尝试使用NuGet安装Selenium.Webdriver,但出现此错误:
Cannot find any .csproj or .fsproj for your project! Please fix this error.
我肯定会忽略一些基本知识。什么事?
答案 0 :(得分:1)
建议您使用“ keypoints
”在当前的python environment中安装模块“ pip
”:
检查安装工具“ selenium
”是否来自当前选择的环境:
使用命令“ pip
”或“ pip install selenium
”安装模块。
检查安装是否成功:“ pip3 install selenium
”或“ pip list
”
运行:
更多参考资料:Use Python in VSCode。