简体   繁体   English

Chromedriver 文本文件忙

[英]Chromedriver text file busy

I have an app that runs selenium and does some testing.我有一个运行 selenium 并进行一些测试的应用程序。 when I run my code in stand-alone, it works perfectly.当我独立运行我的代码时,它可以完美运行。 But when I run it several times, to test multiple things in the same time, I get an error.但是当我多次运行它以同时测试多个东西时,我得到了一个错误。

Here is my code:这是我的代码:

    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')
    chrome_options.add_argument("window-size=1920,1080")
    chrome_options.add_argument("--disable-features=NetworkService")
    driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)
    driver.get(URL)

and here's the error这是错误

    files = self.__unpack(file_path)
    File "/usr/local/lib/python3.6/dist-packages/webdriver_manager/driver_cache.py", line 99, in __unpack
    return extract_zip(path, to_directory)
    File "/usr/local/lib/python3.6/dist-packages/webdriver_manager/archive.py", line 7, in extract_zip
    archive.extractall(to_directory)
    File "/usr/lib/python3.6/zipfile.py", line 1524, in extractall
    self._extract_member(zipinfo, path, pwd)
    File "/usr/lib/python3.6/zipfile.py", line 1578, in _extract_member
    open(targetpath, "wb") as target:
    OSError: [Errno 26] Text file busy: '/home/root/.wdm/drivers/chromedriver/80.0.3987.106/linux64/chromedriver'

my understanding is that there is an instance of chromedriver which is already running, which is possible as I can run this code in the background.我的理解是有一个 chromedriver 实例已经在运行,这是可能的,因为我可以在后台运行此代码。 How can I handle this error?我该如何处理这个错误?

I believe you are right: the error happens when there is already an instance of chrome running.我相信你是对的:当已经有一个 chrome 实例正在运行时,就会发生错误。

To fix first find the processes running chrome .要修复首先找到运行chrome的进程。 You can do this by search processes which contain the name chrome like so:您可以通过包含名称chrome的搜索过程来执行此操作,如下所示:

pidof chrome

Then you can kill all of them like so:然后你可以像这样杀死所有的人:

pkill -f chrome

Re-running your code afterwards should not produce this error.之后重新运行您的代码不应产生此错误。

I meet this error recently, I tried "rsync" to copy the chromedriver to a new directory, then update the environment variable to the new path, and it works.我最近遇到这个错误,我尝试“rsync”将chromedriver复制到一个新目录,然后将环境变量更新到新路径,它可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OSError: [Errno 26] 文本文件繁忙 - OSError: [Errno 26] Text file busy 多线程python上的“文本文件繁忙”错误 - “Text file busy” error on multithreading python Hadoop流作业执行中映射器的“文本文件繁忙”错误 - “Text file busy” error for the mapper in a Hadoop streaming job execution AWS Lambda “errorMessage”:“[Errno 26] 文本文件忙” - AWS Lambda "errorMessage": "[Errno 26] Text file busy" OError: [Errno 26] 文本文件忙:'/...myvirtualenv/bin/python' - OError: [Errno 26] Text file busy: '/…myvirtualenv/bin/python' OSError: [Errno 26] 文本文件忙于使用 synced_folder 的 vagrant - OSError: [Errno 26] Text file busy on vagrant with synced_folder 在Python中检查文件是否已打开(由于错误:“文本文件正忙”) - Check if files are open (because of error: “text file busy”) in Python 尝试执行临时文件时,Python给出“ OSError:文本文件正忙” - Python gives “OSError: Text file busy” upon trying to execute temporary file 使用 .sh 文件 python 安装库和依赖项([Errno 26] 文本文件繁忙) - install libraries and dependencies with .sh file python ([Errno 26] Text file busy) 子进程中断管道并且文件繁忙 - subprocess breaking pipes and file busy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM