Unknown error: devtoolsactivport file doesn’t exist
In the morning, there was a problem when starting Chrome with selenium under Linux: error:
Traceback (most recent call last):
File "get2.py", line 62, in <module>
browser = webdriver.Chrome()
File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 311, in execute
self.error_handler.check_response(response)
File "/root/.pyenv/versions/anaconda3-5.1.0/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.9.0-6-amd64 x86_64)
Solution: add code:
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--headless')
browser = webdriver.Chrome(chrome_options=chrome_options)
The “– no sandbox” parameter allows chrome to run under the root permission, and the “– headless” parameter allows chrome to have a better experience without opening the graphical interface
The “– no sandbox” parameter allows chrome to run under the root permission, and the “– headless” parameter allows chrome to have a better experience without opening the graphical interface
chrome_options.add_argument('blink-settings=imagesEnabled=false')
chrome_options.add_argument('--disable-gpu')
Similar Posts:
- Error reporting in Firefox using selenium in Python
- Under Ubuntu system, selenium opens the Firefox browser and prompts’ unable to find a matching set of capabilities. And message: connect
- selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
- [Solved] Error in Python selenium + phantom JS alert() pop-up window
- Selenium Error: Message: unknown error: cannot find Chrome binary
- [Solved] Pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
- Message: ‘geckodriver’ executable needs to be in PATH. [Solved]
- Symbol not found: __PyCodecInfo_GetIncrementalDecoder
- Mac environment and python + selenium environment are built to solve the error reporting problem of chromedriver
- Solve the problem of import error: cannot import name webriver