ValueError: I/O operation on closed file
This error comes from:
path = os.path.join(os.path.dirname(file), 'bin', 'chromedriver') service = Service(executable_path=path) browser = Browser('chrome', service=service, headless=True)
ValueError: I/O operation on closed file
Traceback (most recent call last): File "/home/ubuntu/splinter/download2.py", line 73, in get_periods browser = Browser('chrome', service=service, headless=True) File "/home/ubuntu/splinter/lib/python3.10/site-packages/splinter/browser.py", line 130, in Browser return get_driver(driver, retry_count=retry_count, config=config, *args, **kwargs) File "/home/ubuntu/splinter/lib/python3.10/site-packages/splinter/browser.py", line 92, in get_driver return driver(config=config, *args, **kwargs) File "/home/ubuntu/splinter/lib/python3.10/site-packages/splinter/driver/webdriver/chrome.py", line 65, in init driver = _setup_chrome( File "/home/ubuntu/splinter/lib/python3.10/site-packages/splinter/driver/webdriver/setup.py", line 36, in _setup_chrome rv = driver_class(options=options, service=service, **kwargs) File "/home/ubuntu/splinter/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in init super().init( File "/home/ubuntu/splinter/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 53, in init self.service.start() File "/home/ubuntu/splinter/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 98, in start self._start_process(self._path) File "/home/ubuntu/splinter/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 205, in _start_process self.process = subprocess.Popen( File "/usr/lib/python3.10/subprocess.py", line 837, in init errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "/usr/lib/python3.10/subprocess.py", line 1638, in _get_handles c2pwrite = stdout.fileno() ValueError: I/O operation on closed file
splinter version: 0.20.1 selenium version: 4.15.2 ChromeDriver 120.0.6099.62
We're seeing the same error with:
splinter version: 0.19.1 selenium version: 4.14.0 ChromeDriver 119.0.6045.105
I can't reproduce this using:
-
splinter 0.21.0
-
selenium 4.17.2
-
chromedriver 121.0.6167.85
Workaround was:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
browser = Browser('chrome', options=chrome_options, headless=True)
Seems to work