Instapy: (unknown error: DevToolsActivePort file doesn't exist)

Created on 13 Aug 2018  路  20Comments  路  Source: timgrossmann/InstaPy

Current Behavior

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.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 4.4.0-131-generic x86_64)
Traceback (most recent call last):
  File "/root/InstaPy/instapy/instapy.py", line 300, in set_selenium_local_session
    chrome_options=chrome_options)
  File "/root/venv/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "/root/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "/root/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 251, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/root/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "/root/venv/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
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.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 4.4.0-131-generic x86_64)

Traceback (most recent call last):
  File "quickstart.py", line 23, in <module>
    multi_logs=True)
  File "/root/InstaPy/instapy/instapy.py", line 193, in __init__
    self.set_selenium_local_session()
  File "/root/InstaPy/instapy/instapy.py", line 304, in set_selenium_local_session
    Settings.chromedriver_location))
instapy.instapy.InstaPyError: ensure chromedriver is installed at /root/InstaPy/assets/chromedriver

My Configuration File :

import os
import time
from tempfile import gettempdir

from selenium.common.exceptions import NoSuchElementException

from instapy import InstaPy

insta_username = 'xxxx'
insta_password = 'xxxx'

# set headless_browser=True if you want to run InstaPy on a server

# set these in instapy/settings.py if you're locating the
# library in the /usr/lib/pythonX.X/ directory:
#   Settings.database_location = '/path/to/instapy.db'
#   Settings.chromedriver_location = '/path/to/chromedriver'

session = InstaPy(username=insta_username,
                  password=insta_password,
                  headless_browser=False,
                  nogui=True,
                  multi_logs=True)

try:
    session.login()

    # settings
    session.set_relationship_bounds(enabled=True,
                                 potency_ratio=-1.21,
                                  delimit_by_numbers=True,
                                   max_followers=4590,
                                    max_following=5555,
                                     min_followers=45,
                                      min_following=77)
    session.set_do_comment(True, percentage=10)
    session.set_comments(['aMEIzing!', 'So much fun!!', 'Nicey!'])
    session.set_dont_include(['friend1', 'friend2', 'friend3'])
    session.set_dont_like(['pizza', 'girl'])

    # actions
    session.like_by_tags(['natgeo'], amount=1)

except Exception as exc:
    # if changes to IG layout, upload the file to help us locate the change
    if isinstance(exc, NoSuchElementException):
        file_path = os.path.join(gettempdir(), '{}.html'.format(time.strftime('%Y%m%d-%H%M%S')))
        with open(file_path, 'wb') as fp:
            fp.write(session.browser.page_source.encode('utf8'))
        print('{0}\nIf raising an issue, please also upload the file located at:\n{1}\n{0}'.format(
            '*' * 70, file_path))
    # full stacktrace when raising Github issue
    raise

finally:
    # end the bot session
    session.end()

But work for headless_browser=True then i can't use Proxy . is it Chrome issue ?

wontfix

Most helpful comment

I'm facing the same issue. Please don't close it.

All 20 comments

as the last error message pointed out instapy.instapy.InstaPyError: ensure chromedriver is installed at /root/InstaPy/assets/chromedriver

please make sure you have the latest Chromedriver in your assets folder

yes last Google chrome and Chrome Driver installed .

i was able to resolve this with using the chromedriver beta from electron:

the lastest release from this page https://github.com/electron/electron/releases

in my case (raspberry pi / stretch 4) this was:
https://github.com/electron/electron /releases/download/v3.0.0-beta.5/chromedriver-v3.0.0-beta.5-linux-armv7l.zip

installed chromium-browser via apt-get (v68) and then pip install the dependencies.
worked like charme... hopefully this helps somebody

@gherkins are u using headless_browser=False , i try but not work in Ubuntu .

@Mehran did you pick the right chromedriver version for your OS?
should be https://github.com/electron/electron/releases/download/v3.0.0-beta.5/chromedriver-v3.0.0-beta.5-linux-x64.zip for a 64 ubuntu...

@gherkins Yes sure , i also try below for test

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
driver = webdriver.Chrome('/root/driver/chromedriver')

but not working , i think you try it on RaspberryPi right ?

yep, on raspberry, but similar issues...

do you have sufficient permissions for /root/driver ?

also did you try running chromedriver manually with the verbose option?
./chromedriver --verbose then call it via curl for example

curl -XPOST http://localhost:9515/session -d '{"desiredCapabilities":{"browserName":"chrome"}}'

in my case even that was throwing errors (never worked though) but i got less errors w/ the electron version, and that version then worked with python...

@gherkins Yes permission is okey .
when i comment #chrome_options.add_argument('--headless')its work and when uncomment not work .
it something on Google Chrome or Driver issue ..

@Mehran it sounds like whatever version/platform you are using for chromedriver doesn't support that flag.

@CharlesCCC i try Ubuntu 14,16,18 debian 9 with last google-chrome-stable and driver but same, when i not use --headless chrome crash, what os u tested?

same error

Hi ,

 I have already using the https://github.com/electron/electron/releases/download/v3.0.0-beta.5/chromedriver-v3.0.0-beta.5-linux-x64.zip for a 64 ubuntu..., , but still have the following error !

whats wrong !

root@ubuntu:~/InstaPy/assets# ls -ltr
total 10132
-rw-r--r-- 1 root root 489 Aug 28 08:01 unicodes.md
-rwxr-xr-x 1 root root 10367352 Aug 28 19:47 chromedriver

root@ubuntu:~/InstaPy/assets# cd ..
root@ubuntu:~/InstaPy# python3 quickstart.py
ERROR [2018-08-28 19:51:11] [nova168168] Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.36 (a81166ad79e68fbfe7cf5ba243192d6412e26b37),platform=Linux 4.4.0-87-generic x86_64)
Traceback (most recent call last):
File "/root/InstaPy/instapy/instapy.py", line 300, in set_selenium_local_session
chrome_options=chrome_options)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.36 (a81166ad79e68fbfe7cf5ba243192d6412e26b37),platform=Linux 4.4.0-87-generic x86_64)

Traceback (most recent call last):
File "/root/InstaPy/instapy/instapy.py", line 300, in set_selenium_local_session
chrome_options=chrome_options)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.36 (a81166ad79e68fbfe7cf5ba243192d6412e26b37),platform=Linux 4.4.0-87-generic x86_64)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "quickstart.py", line 22, in
multi_logs=True)
File "/root/InstaPy/instapy/instapy.py", line 193, in __init__
self.set_selenium_local_session()
File "/root/InstaPy/instapy/instapy.py", line 304, in set_selenium_local_session
Settings.chromedriver_location))
instapy.instapy.InstaPyError: ensure chromedriver is installed at /root/InstaPy/assets/chromedriver

Nova

same error

The same issue exist on windows 10.

I followed all the steps from this reference : http://chromedriver.chromium.org/help/chrome-doesn-t-start

Chrome Driver: 2.42.591088 [Supports Chrome v68-70]
Chrome browser: 69.0.3497.100 (Official Build) (64-bit)

Here's the exception:
WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:/Program Files (x86)/Google/Chrome/Application/chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.16299 x86_64)

Do we have an alternate solution for this issue?

I fixed something similar to this by commenting the following line. When I pull, I always have to bring in this one change. I'm sure there's a better way. This is only an issue when I run for the first time to get past the security question, and then I go back to headless.

[dmathis@CentOS InstaPy]$ diff instapy/instapy.py ../InstaPy.2018.10.07/instapy/instapy.py
296c296
<             chrome_options.add_argument('--disable-setuid-sandbox')
---
>             # chrome_options.add_argument('--disable-setuid-sandbox')

So far no solution available. Anyone is looking at the issue ?

The problem was fixed when I changed the headless_browser=True and no_gui=False.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this problem still occurs, please open a new issue

I'm facing the same issue. Please don't close it.

The problem was fixed when I changed the headless_browser=True and no_gui=False.

How to set " no_gui=False.". Please let me know. Thanks so much

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

converge picture converge  路  3Comments

ediooo picture ediooo  路  3Comments

neomh picture neomh  路  3Comments

ingorichter picture ingorichter  路  3Comments