unknown command "selenium"

时间: 2023-07-07 13:45:39 浏览: 49
如果你在终端或命令提示符中输入`pip selenium`后出现`unknown command "selenium"`的错误提示,可能是因为`selenium`不是一个可执行的命令。你需要使用`pip`命令来安装`selenium`库,安装完成后才能在Python代码中使用`selenium`库的各种方法和函数。 请尝试在终端或命令提示符中输入以下命令来安装`selenium`库: ``` pip install selenium ``` 如果你依然无法安装或使用`selenium`库,请提供更详细的错误信息以便我能够更好地帮助你解决问题。
相关问题

selenium.common.exceptions.WebDriverException: Message: unknown command: Page.addScriptToEvalueteOnNewDcument wasn t found

这个错误通常是由于Selenium版本不兼容导致的。在Selenium 4.0中,一些命令已被弃用或更改,因此旧版本的代码可能无法在新版本中正常工作。具体来说,错误信息中提到的命令“Page.addScriptToEvaluateOnNewDocument”已被弃用,因此需要使用新的命令“Page.addScriptToEvaluateOnNewDocumentOnLoad”来替换它。 以下是一个示例代码,演示如何使用新的命令来添加脚本: ```python from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument('--disable-extensions') options.add_argument('--headless') options.add_argument('--disable-gpu') options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') options.add_argument('--remote-debugging-port=9222') driver = webdriver.Chrome(options=options) driver.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocumentOnLoad', { 'source': 'console.log("Hello, world!");' }) driver.get('https://www.google.com') ``` 在这个示例中,我们使用了Selenium 4.0中的新命令“execute_cdp_cmd”来执行CDP(Chrome DevTools Protocol)命令。我们使用“Page.addScriptToEvaluateOnNewDocumentOnLoad”命令来添加一个简单的脚本,该脚本在每次加载新文档时都会运行,并在控制台中输出“Hello, world!”。

selenium.common.exceptions.WebDriverException: Message: unknown command: 'Page.addScriptToEvalueteOnNewDcument' wasn't found

这个错误通常是由于Selenium版本不兼容导致的。在Selenium 4.0中,WebDriver API已经升级为W3C标准,而之前的非W3C标准API已被弃用。因此,如果您的代码使用了旧的非W3C标准API,就会出现这个错误。 解决这个问题的方法是升级您的代码以使用新的W3C标准API。如果您使用的是Selenium 3.x版本,则需要将代码升级到Selenium 4.0版本。如果您使用的是Selenium 4.0版本,则需要检查您的代码是否使用了旧的非W3C标准API,并将其替换为新的W3C标准API。 以下是一个使用新的W3C标准API的示例代码: ```python from selenium import webdriver driver = webdriver.Chrome() # 使用新的W3C标准API来滚动到页面底部 driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") ```

相关推荐

情分析以下错误:Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"search-input"} Command duration or timeout: 3.97 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.40.0', revision: 'fbe29a9', time: '2014-02-19 20:54:28' System info: host: 'LAPTOP-34K1M0P4', ip: '192.168.32.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=13.0.1, platform=XP, browserConnectionEnabled=true, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: 450cd28c-219b-444e-a9ff-427428c704f0 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:326) at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:367) at org.openqa.selenium.By$ById.findElement(By.java:214) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:318) at shiyan2.crawler.main(crawler.java:18) Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"id","selector":"search-input"} Build info: version: '2.40.0', revision: 'fbe29a9', time: '2014-02-19 20:54:28' System info: host: 'LAPTOP-34K1M0P4', ip: '192.168.32.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201' Driver info: driver.version: unknown at <anonymous class>.<anonymous method>(file:///C:/Users/Y/AppData/Local/Temp/anonymous3190348505889140058webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js:8904) at <anonymous class>.<anonymous method>(file:///C:/Users/Y/AppData/Local/Temp/anonymous3190348505889140058webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js:8913) at <anonymous class>.<anonymous method>(file:///C:/Users/Y/AppData/Local/Temp/anonymous3190348505889140058webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10878) at <anonymous class>.<anonymous method>(file:///C:/Users/Y/AppData/Local/Temp/anonymous3190348505889140058webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10883) at <anonymous class>.<anonymous method>(file:///C:/Users/Y/AppData/Local/Temp/anonymous3190348505889140058webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10825)

Traceback (most recent call last): File "D:\pythonsthl\flaskProject\SeleniumTest\21Test.py", line 19, in <module> driver = webdriver.Chrome(options=options) File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 49, in __init__ super().__init__( File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 54, in __init__ super().__init__( File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in __init__ self.start_session(capabilities) File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 291, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute self.error_handler.check_response(response) File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: was killed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location C:\\Users\\24972\\Downloads\\chromedriver_win32\\chromedriver.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Stacktrace: Backtrace: GetHandleVerifier [0x00D8A813+48355] (No symbol) [0x00D1C4B1] (No symbol) [0x00C25358] (No symbol) [0x00C43621] (No symbol) [0x00C40579] (No symbol) [0x00C70C55] (No symbol) [0x00C7093C] (No symbol) [0x00C6A536] (No symbol) [0x00C482DC] (No symbol) [0x00C493DD] GetHandleVerifier [0x00FEAABD+2539405] GetHandleVerifier [0x0102A78F+2800735] GetHandleVerifier [0x0102456C+2775612] GetHandleVerifier [0x00E151E0+616112] (No symbol) [0x00D25F8C] (No symbol) [0x00D22328] (No symbol) [0x00D2240B] (No symbol) [0x00D14FF7] BaseThreadInitThunk [0x75A77D59+25] RtlInitializeExceptionChain [0x76EDB79B+107] RtlClearBits [0x76EDB71F+191] Process finished with exit code 1

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. ===================== RESTART: G:\chashan\python案例\爬虫案例.py ===================== Traceback (most recent call last): File "G:\chashan\python案例\爬虫案例.py", line 3, in <module> driver = webdriver.Chrome() File "G:\chashan\python\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 84, in __init__ super().__init__( File "G:\chashan\python\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 104, in __init__ super().__init__( File "G:\chashan\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 286, in __init__ self.start_session(capabilities, browser_profile) File "G:\chashan\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 378, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "G:\chashan\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "G:\chashan\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary Stacktrace: Backtrace: GetHandleVerifier [0x010F8893+48451] (No symbol) [0x0108B8A1] (No symbol) [0x00F95058] (No symbol) [0x00FB164E] (No symbol) [0x00FB0019] (No symbol) [0x00FE0798] (No symbol) [0x00FE047C] (No symbol) [0x00FDA0B6] (No symbol) [0x00FB7E08] (No symbol) [0x00FB8F2D] GetHandleVerifier [0x01358E3A+2540266] GetHandleVerifier [0x01398959+2801161] GetHandleVerifier [0x0139295C+2776588] GetHandleVerifier [0x01182280+612144] (No symbol) [0x01094F6C] (No symbol) [0x010911D8] (No symbol) [0x010912BB] (No symbol) [0x01084857] BaseThreadInitThunk [0x75587D59+25] RtlInitializeExceptionChain [0x76FBB74B+107] RtlClearBits [0x76FBB6CF+191]

C:\Users\31114> & C:/Users/31114/AppData/Local/Microsoft/WindowsApps/python3.8.exe c:/Users/31114/Untitled-1.py c:/Users/31114/Untitled-1.py:8: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Chrome(executable_path=driver_path) Traceback (most recent call last): File "c:/Users/31114/Untitled-1.py", line 8, in <module> driver = webdriver.Chrome(executable_path=driver_path) File "C:\Users\31114\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\chrome\webdriver.py", line 84, in __init__ super().__init__( File "C:\Users\31114\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\chromium\webdriver.py", line 104, in __init__ super().__init__( File "C:\Users\31114\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 286, in __init__ self.start_session(capabilities, browser_profile) File "C:\Users\31114\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 378, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\31114\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "C:\Users\31114\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary Stacktrace: Backtrace: GetHandleVerifier [0x00CAA813+48355] (No symbol) [0x00C3C4B1] (No symbol) [0x00B45358] (No symbol) [0x00B61A9E] (No symbol) [0x00B60579] (No symbol) [0x00B90C55] (No symbol) [0x00B9093C] (No symbol) [0x00B8A536] (No symbol) [0x00B682DC] (No symbol) [0x00B693DD] GetHandleVerifier [0x00F0AABD+2539405] GetHandleVerifier [0x00F4A78F+2800735] GetHandleVerifier [0x00F4456C+2775612] GetHandleVerifier [0x00D351E0+616112] (No symbol) [0x00C45F8C] (No symbol) [0x00C42328] (No symbol) [0x00C4240B] (No symbol) [0x00C34FF7] BaseThreadInitThunk [0x75AD7D59+25] RtlInitializeExceptionChain [0x77D3B74B+107] RtlClearBits [0x77D3B6CF+191]代码为此错误,更改

最新推荐

recommend-type

grpcio-1.63.0-cp38-cp38-linux_armv7l.whl

Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
recommend-type

SQLyog-13.1.3-0.x86Community.exe

SQLyog-13.1.3-0.x86Community
recommend-type

VB自动出题题库系统设计(源代码+系统).rar

计算机专业毕业设计VB精品论文资源
recommend-type

debugpy-1.0.0b2-cp35-cp35m-manylinux1_i686.whl

Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
recommend-type

实战自学python如何成为大佬(目录):https://blog.csdn.net/weixin-67859959/artic

实战自学python如何成为大佬(目录):https://blog.csdn.net/weixin-67859959/artic
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

用Spring boot和vue写一个登录注册界面

好的,这是一个比较常见的技术问题,我可以为您提供一些参考资料和思路。首先,您可以使用Spring Boot作为后端框架来处理用户认证和注册的逻辑,比如使用Spring Security实现用户登录认证。同时,您还需要设计相应的数据模型和数据库表结构来存储用户信息。在前端方面,您可以使用Vue.js作为框架来构建登录注册页面,使用Axios来发起API请求并和后端进行交互。当然,在实现过程中,还需要考虑一些具体细节,比如数据校验、安全性和用户体验等方面。希望这些信息能够帮助到您。
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。