Unable to start chrome browser with selenium and getting error "DevToolsActivePort" file doesn't exist with PyCharm

Hi

I am unable to start chrome browser with selenium, when running the script in PyCharm, getting "DevToolsActivePort" file doesn't exist error, below is the stacktrace. When i execute the same script through Python IDLE, i am able to run with out any issue. I tried with chrome options but nothing is working. I dont understand why it is able to execute with Pythin IDLE and why not with PyCharm. i am not sure is there any different execution processes for both.It would be great if you can look into the issue.

i am using PyCharm Community Edition 2019.3.3_001 with Python 3.7

File "C:\Users\Shiva\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
(Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 10.0.16299 x86_64)

9 comments
Comment actions Permalink

Do you use the same interpreter when running it in Python IDLE?

Try copying the executed by PyCharm command and running it from the CMD.

0
Comment actions Permalink

Thanks for the quick response.

Yes...I am using same interpreter in both cases.

I tried running it as below:

PyCharm's Terminal: Un Successful (Getting same error)

Above Command in CMD: Successful

PyCharm's Python Console: Un Succesful (Getting same error)

One Observation: When i navigate to PyCharm's Python Console tab, i can see the below error after sys.path.extend....line

"Unable to load extension pydevd_plugins.extensions.types.pydevd_plugins_django_form_str""

Python Console

>>>

I am not sure whether above error in loading extension is causing the issue. If yes, please let me know how to fix it.

 

0
Comment actions Permalink

Hmm, perhaps there is a difference in runtime.

Is there a chance you could share your code or a minimal example for reproducing the issue?

0
Comment actions Permalink

I have the same setup in my personal laptop, cant see the above loading extension error in Python Console, it is working fine. Not able to reproduce the issue in personal laptop.

I am getting the issue in office machine and it happens with other employees as well and it happens with Chrome browser only.

Prerequisite: selenium 3.141 package, chromedriver 2.40.565498 (or you can use browser version compatible chromedriver)

Below is the code:

from selenium import webdriver

driver = webdriver.Chrome(executable_path=<path to chromedriver.exe>)

driver.maximize_window()

driver.get("https://www.jetbrains.com/")     #I have replaced my application URL to jetbrains

driver.close()

driver.quit()

 

0
Comment actions Permalink

I can't reproduce it with ChromeDriver 83.0.4103.39 and selenium 3.141.0

Could you make sure you use the latest Chrome and ChromeDriver versions?

From https://bugs.chromium.org/p/chromedriver/issues/detail?id=2473:

There is a particular workaround which involves passing the flags "--no-sandbox" and "--disable-dev-shm-usage" into Chrome on startup.

0
Comment actions Permalink

Yes. I tried with chrome browser compatible chromedriver as well and Chrome option with "--no-sandbox" and "--disable-dev-shm-usage". Also tried by passing other options too "--headless", "--disable-gpu" and "--remote-debugging-port=9222, none of them are working. My issue looks typical as it is working fine with Python IDLE and not with PyCharm.

0
Comment actions Permalink

What PyCharm and Python versions do you use?
Do you use any 3rd party plugins?

0
Comment actions Permalink

PyCharm Community Edition 2019.3.3_001 and Python 3.7. I am not using any third party plugins.

0
Comment actions Permalink

Works fine in my environment with the same versions.
Could you compare PATH and PYTHONPATH environment variables between running in PyCharm and in the CMD? I think there should be some differences that would explain the problem.

0

Please sign in to leave a comment.