Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

undetected_chromedriver unable to init #381

Closed
Liu-Angelo opened this issue Dec 28, 2022 · 38 comments
Closed

undetected_chromedriver unable to init #381

Liu-Angelo opened this issue Dec 28, 2022 · 38 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Liu-Angelo
Copy link

Spawning browser...
Traceback (most recent call last):
File "/data/chatgpt/bin/revChatGPT/ChatGPT.py", line 404, in get_cf_cookies
browser_executable_path=self.config.get("browser_exec_path")
File "/usr/local/lib/python3.6/site-packages/undetected_chromedriver/init.py", line 51, in new
instance.init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'enable_cdp_events'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/chatgpt/bin/chatgpt_app.py", line 10, in
chatbot = Chatbot(config, conversation_id=None)
File "/data/chatgpt/bin/revChatGPT/ChatGPT.py", line 77, in init
self.get_cf_cookies()
File "/data/chatgpt/bin/revChatGPT/ChatGPT.py", line 416, in get_cf_cookies
driver.quit()
UnboundLocalError: local variable 'driver' referenced before assignment
Spawning browser...
Traceback (most recent call last):
File "/data/chatgpt/bin/revChatGPT/ChatGPT.py", line 404, in get_cf_cookies
browser_executable_path=self.config.get("browser_exec_path")
File "/usr/local/lib/python3.6/site-packages/undetected_chromedriver/init.py", line 51, in new
instance.init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'enable_cdp_events'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/chatgpt/bin/chatgpt_app.py", line 10, in
chatbot = Chatbot(config, conversation_id=None)
File "/data/chatgpt/bin/revChatGPT/ChatGPT.py", line 77, in init
self.get_cf_cookies()
File "/data/chatgpt/bin/revChatGPT/ChatGPT.py", line 416, in get_cf_cookies
driver.quit()
UnboundLocalError: local variable 'driver' referenced before assignment

What is the reason for the above error when executing?

@acheong08
Copy link
Owner

Can you give some system details?
OS: (Linux/Windows/MacOS)

@acheong08
Copy link
Owner

TypeError: init() got an unexpected keyword argument 'enable_cdp_events'

This is a very strange error because enable_cdp_events is most definitely a parameter.

    def __init__(
        self,
        options=None,
        user_data_dir=None,
        driver_executable_path=None,
        browser_executable_path=None,
        port=0,
        enable_cdp_events=False,
        service_args=None,
        service_creationflags=None,
        desired_capabilities=None,
        advanced_elements=False,
        service_log_path=None,
        keep_alive=True,
        log_level=0,
        headless=False,
        version_main=None,
        patcher_force_close=False,
        suppress_welcome=True,
        use_subprocess=True,
        debug=False,
        no_sandbox=True,
        **kw,
    ):

@acheong08
Copy link
Owner

File "/usr/local/lib/python3.6...

Python 3.6 is not supported. We only support Python 3.10 and above

@fanxioanan
Copy link

Can you give some system details? OS: (Linux/Windows/MacOS)

I have same question. Linux(Centos 7.4) python 3.10.8

@acheong08
Copy link
Owner

You might be using an old version of selenium. Do pip3 show selenium

@acheong08
Copy link
Owner

Try https://github.com/acheong08/ChatGPT/releases/tag/0.0.48.2 which enforces the dependency versions

@FerretCode
Copy link

FerretCode commented Dec 28, 2022

I'm also experiencing this issue. It works on Arch for me, running Python 3.10.9. However, on Ubuntu using the same version of python, I get the UnboundLocalError: local variable 'driver' referenced before assignment error. Same with running in a Docker container based on Debian

@FerretCode
Copy link

All of my dependencies are upgraded & the latest version of the package is installed on both Arch and Ubuntu.

@FerretCode
Copy link

FerretCode commented Dec 28, 2022

Looks like some of my packages weren't upgraded on the Ubuntu system. It's now giving this warning: RequestsDependencyWarning: urllib3 (1.26.13) or chardet (3.0.4) doesn't match a supported version! warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "

What are the supported versions of these packages?

All of the dependencies directly required by this library meet the required versions

@FerretCode
Copy link

Full stacktrace:

/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (5.1.0) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Spawning browser...

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/revChatGPT/ChatGPT.py", line 401, in get_cf_cookies
    driver = uc.Chrome(
  File "/usr/local/lib/python3.10/dist-packages/undetected_chromedriver/__init__.py", line 411, in __init__
    browser = subprocess.Popen(
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1722, in _execute_child
    and os.path.dirname(executable)
  File "/usr/lib/python3.10/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/dominion-skynet/commands/../main.py", line 15, in <module>
    chatbot = Chatbot({
  File "/usr/local/lib/python3.10/dist-packages/revChatGPT/ChatGPT.py", line 77, in __init__
    self.get_cf_cookies()
  File "/usr/local/lib/python3.10/dist-packages/revChatGPT/ChatGPT.py", line 416, in get_cf_cookies
    driver.quit()
UnboundLocalError: local variable 'driver' referenced before assignment

@FerretCode
Copy link

I haven't tested it yet, but I submitted a PR for a potential fix for this

@Liu-Angelo
Copy link
Author

Can you give some system details? OS: (Linux/Windows/MacOS)

  • Linux version 3.10.107
  • ChatGPT-0.0.48.2
  • python3.7.2

------------ run error -------

python3 main.py

Traceback (most recent call last):
File "main.py", line 6, in
from ChatGPT import Chatbot
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/ChatGPT.py", line 5, in
import undetected_chromedriver as uc
File "/usr/local/python3/lib/python3.7/site-packages/undetected_chromedriver/init.py", line 46, in
from .webelement import UCWebElement
File "/usr/local/python3/lib/python3.7/site-packages/undetected_chromedriver/webelement.py", line 5, in
class WebElement(selenium.webdriver.remote.webelement.WebElement):
File "/usr/local/python3/lib/python3.7/site-packages/undetected_chromedriver/webelement.py", line 12, in WebElement
) -> list[selenium.webdriver.remote.webelement.WebElement]:
TypeError: 'type' object is not subscriptable

@acheong08
Copy link
Owner

Try the following:

  1. Update python. 3.10 is the officially supported version
  2. Update selenium. 4.7.2 is the officially supported version

@Liu-Angelo
Copy link
Author

The following error still occurs in ChatGPT-0.0.47.2

ChatGPT-0.0.47.2/src/revChatGPT# python3 main.py
Traceback (most recent call last):
File "main.py", line 5, in
from ChatGPT import Chatbot
File "/data/ChatGPT-0.0.47.2/src/revChatGPT/ChatGPT.py", line 5, in
import undetected_chromedriver as uc
File "/usr/local/python3/lib/python3.7/site-packages/undetected_chromedriver/init.py", line 46, in
from .webelement import UCWebElement
File "/usr/local/python3/lib/python3.7/site-packages/undetected_chromedriver/webelement.py", line 5, in
class WebElement(selenium.webdriver.remote.webelement.WebElement):
File "/usr/local/python3/lib/python3.7/site-packages/undetected_chromedriver/webelement.py", line 12, in WebElement
) -> list[selenium.webdriver.remote.webelement.WebElement]:
TypeError: 'type' object is not subscriptable

@acheong08
Copy link
Owner

I said update selenium, not revChatGPT:
"Update selenium. 4.7.2 is the officially supported version" pip3 install selenium==4.7.2

@acheong08
Copy link
Owner

And again. Please update Python

@acheong08
Copy link
Owner

@Liu-Angelo
Copy link
Author

And use https://github.com/acheong08/ChatGPT/releases/tag/0.0.48.2

  • Linux version 3.10.107
  • ChatGPT-0.0.48.2
  • python3.10.4
  • selenium==4.7.2
    ------------ run error -------

python3 main.py
ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
Repo: github.com/acheong08/ChatGPT

Type '!help' to show commands
Press enter twice to submit your question.

Logging in...
Spawning browser...
Traceback (most recent call last):
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/ChatGPT.py", line 401, in get_cf_cookies
driver = uc.Chrome(
File "/usr/local/lib/python3.10/site-packages/undetected_chromedriver/init.py", line 242, in init
patcher.auto()
File "/usr/local/lib/python3.10/site-packages/undetected_chromedriver/patcher.py", line 127, in auto
release = self.fetch_release_number()
File "/usr/local/lib/python3.10/site-packages/undetected_chromedriver/patcher.py", line 148, in fetch_release_number
return LooseVersion(urlopen(self.url_repo + path).read().decode())
File "/usr/local/lib/python3.10/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.10/urllib/request.py", line 519, in open
response = self._open(req, data)
File "/usr/local/lib/python3.10/urllib/request.py", line 541, in _open
return self._call_chain(self.handle_open, 'unknown',
File "/usr/local/lib/python3.10/urllib/request.py", line 496, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.10/urllib/request.py", line 1419, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/main.py", line 114, in
main()
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/main.py", line 110, in main
chatGPT_main(configure())
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/main.py", line 45, in chatGPT_main
chatbot = Chatbot(config)
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/ChatGPT.py", line 77, in init
self.get_cf_cookies()
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/ChatGPT.py", line 416, in get_cf_cookies
driver.quit()

@Liu-Angelo
Copy link
Author

pip3 show selenium

Name: selenium
Version: 4.7.2
Summary:
Home-page: https://www.selenium.dev
Author:
Author-email:
License: Apache 2.0
Location: /usr/local/lib/python3.10/site-packages
Requires: certifi, trio, trio-websocket, urllib3
Required-by: undetected-chromedriver

@acheong08
Copy link
Owner

That is very strange. How about

 $ pip3 show undetected_chromedriver
Name: undetected-chromedriver
Version: 3.1.7
Summary: ('Selenium.webdriver.Chrome replacement with compatiblity for Brave, and other Chromium based browsers.', 'Not triggered by CloudFlare/Imperva/hCaptcha and such.', 'NOTE: results may vary due to many factors. No guarantees are given, except for ongoing efforts in understanding detection algorithms.')
Home-page: https://github.com/ultrafunkamsterdam/undetected-chromedriver
Author: UltrafunkAmsterdam
Author-email: info@blackhat-security.nl
License: GPL-3.0
Location: /home/acheong/.local/lib/python3.10/site-packages
Requires: requests, selenium, websockets
Required-by: revChatGPT

@acheong08 acheong08 added bug Something isn't working help wanted Extra attention is needed labels Dec 29, 2022
@acheong08 acheong08 changed the title run error undetected_chromedriver unable to init Dec 29, 2022
@alexgain
Copy link

alexgain commented Dec 29, 2022

Running into this same issue. I am using Python 3.9.0 though. The other package versions are correct.
Windows 10 in jupyter-lab.

@alexgain
Copy link

Fixed after
pip install websockets==6.0
and kernel restart.

@acheong08
Copy link
Owner

pip install websockets==6.0

That is strange. Why 6.0 specifically?

@Liu-Angelo
Copy link
Author

python3 main.py

    ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
    Repo: github.com/acheong08/ChatGPT

Type '!help' to show commands
Press enter twice to submit your question.

Logging in...
Spawning browser...
Traceback (most recent call last):
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/ChatGPT.py", line 401, in get_cf_cookies
driver = uc.Chrome(
File "/usr/local/lib/python3.10/site-packages/undetected_chromedriver/init.py", line 242, in init
patcher.auto()
File "/usr/local/lib/python3.10/site-packages/undetected_chromedriver/patcher.py", line 127, in auto
release = self.fetch_release_number()
File "/usr/local/lib/python3.10/site-packages/undetected_chromedriver/patcher.py", line 148, in fetch_release_number
return LooseVersion(urlopen(self.url_repo + path).read().decode())
File "/usr/local/lib/python3.10/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.10/urllib/request.py", line 519, in open
response = self._open(req, data)
File "/usr/local/lib/python3.10/urllib/request.py", line 541, in _open
return self._call_chain(self.handle_open, 'unknown',
File "/usr/local/lib/python3.10/urllib/request.py", line 496, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.10/urllib/request.py", line 1419, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/main.py", line 114, in
main()
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/main.py", line 110, in main
chatGPT_main(configure())
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/main.py", line 45, in chatGPT_main
chatbot = Chatbot(config)
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/ChatGPT.py", line 77, in init
self.get_cf_cookies()
File "/data/ChatGPT-0.0.48.2/src/revChatGPT/ChatGPT.py", line 416, in get_cf_cookies
driver.quit()
UnboundLocalError: local variable 'driver' referenced before assignment

@luckseal
Copy link

pip install websockets==6.0

That is strange. Why 6.0 specifically?

when websockets version is 10.4:

Name: websockets
Version: 10.4
Summary: An implementation of the WebSocket Protocol (RFC 6455 & 7692)
Home-page: https://github.com/aaugustin/websockets
Author: Aymeric Augustin
Author-email: aymeric.augustin@m4x.org
License: BSD
Location: C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages
Requires:
Required-by: undetected-chromedriver

the error is :

Spawning browser...
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\revChatGPT\ChatGPT.py", line 401, in get_cf_cookies
    driver = uc.Chrome(
             ^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 409, in __init__
    browser = subprocess.Popen(
              ^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1433, in _execute_child
    args = list2cmdline(args)
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 608, in list2cmdline
    for arg in map(os.fsdecode, seq):
  File "<frozen os>", line 824, in fsdecode
TypeError: expected str, bytes or os.PathLike object, not NoneType

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xxx\Desktop\chatgpt\chat.py", line 3, in <module>
    chatbot = Chatbot({
              ^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\revChatGPT\ChatGPT.py", line 77, in __init__
    self.get_cf_cookies()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\revChatGPT\ChatGPT.py", line 416, in get_cf_cookies
    driver.quit()
    ^^^^^^
UnboundLocalError: cannot access local variable 'driver' where it is not associated with a value

when websockets version is 6.0:

Name: websockets
Version: 6.0
Summary: An implementation of the WebSocket Protocol (RFC 6455 & 7692)
Home-page: https://github.com/aaugustin/websockets
Author: Aymeric Augustin
Author-email: aymeric.augustin@m4x.org
License: BSD
Location: C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages
Requires:
Required-by: undetected-chromedriver

the error is:

Traceback (most recent call last):
  File "C:\Users\xxx\Desktop\chatgpt\chat.py", line 1, in <module>
    from revChatGPT.ChatGPT import Chatbot
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\revChatGPT\ChatGPT.py", line 5, in <module>
    import undetected_chromedriver as uc
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 44, in <module>
    from .cdp import CDP
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\cdp.py", line 9, in <module>
    import websockets
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\websockets\__init__.py", line 3, in <module>
    from .client import *
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\websockets\client.py", line 13, in <module>
    from .extensions.permessage_deflate import ClientPerMessageDeflateFactory
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\websockets\extensions\permessage_deflate.py", line 13, in <module>
    from ..framing import CTRL_OPCODES, OP_CONT
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\websockets\framing.py", line 56, in <module>
    class Frame(FrameData):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\websockets\framing.py", line 76, in Frame
    @asyncio.coroutine
     ^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?

@acheong08
Copy link
Owner

What is your undetected_chromedriver version?

@acheong08
Copy link
Owner

Did you install chrome?

@acheong08
Copy link
Owner

@acheong08
Copy link
Owner

@luckseal
Copy link

Did you install chrome?

thanks.

After I installed the chrome, I solved this problem.

@acheong08
Copy link
Owner

For anyone that gets a chromedriver bug, install Chrome and update selenium and undetected_chromedriver. If errors still occur, Head over to https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues and search

@GSstarGamer
Copy link

For anyone that gets a chromedriver bug, install Chrome and update selenium and undetected_chromedriver. If errors still occur, Head over to https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues and search

I tried everything but still nothing. Even pip install websockets==6.0

@acheong08 acheong08 mentioned this issue Dec 31, 2022
@acheong08
Copy link
Owner

@ArjunSahlot
Copy link

I had a similar issue but I suspect the cause is not having a chromedriver installed.

@acheong08
Copy link
Owner

Check out acheong08/ChatGPT-lite. It solves all the annoying browser problems at the cost of your privacy

@acheong08 acheong08 mentioned this issue Jan 3, 2023
@Liu-Angelo
Copy link
Author

Spawning browser...
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1374, in getresponse
response.begin()
File "/usr/local/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 287, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/revChatGPT/ChatGPT.py", line 401, in get_cf_cookies
driver = uc.Chrome(
File "/usr/local/lib/python3.10/site-packages/undetected_chromedriver/init.py", line 429, in init
super(Chrome, self).init(
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init
super().init(
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 106, in init
super().init(
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 288, in init
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.10/site-packages/undetected_chromedriver/init.py", line 715, in start_session
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 381, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 442, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py", line 294, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py", line 316, in _request
response = self._conn.request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.10/site-packages/urllib3/request.py", line 78, in request
return self.request_encode_body(
File "/usr/local/lib/python3.10/site-packages/urllib3/request.py", line 170, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/usr/local/lib/python3.10/site-packages/urllib3/poolmanager.py", line 376, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 550, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.10/site-packages/urllib3/packages/six.py", line 769, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1374, in getresponse
response.begin()
File "/usr/local/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 287, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/angelo/Work/project/online_space/chatgpt/chatgpt-test/bin/chatgpt_main.py", line 9, in
chatbot = Chatbot(config, conversation_id=None, parent_id=None)
File "/usr/local/lib/python3.10/site-packages/revChatGPT/ChatGPT.py", line 77, in init
self.get_cf_cookies()
File "/usr/local/lib/python3.10/site-packages/revChatGPT/ChatGPT.py", line 416, in get_cf_cookies
driver.quit()
UnboundLocalError: local variable 'driver' referenced before assignment

@spestushko
Copy link

I will leave it here in case it may be helpful for someone. I've been having a similar issue as mentioned above, while running app in a docker container, however, my error stated that Chrome is not reachable. And undetected_chromedriver would eventually timeout without being able to connect.

The error was a result of me starting Xvfb when docker image is being built (i.e. part of the Dockerfile)
Xvfb $DISPLAY -screen $DISPLAY 1280x1024x16 &

Instead, start Xvfb alone with your application's entry point.

For example, my entrypoint in Dockerfile looks like this:

ENTRYPOINT ["./run.sh"]

And my run.sh script looks like this:
The gunicorn may not that relevant to you, but, adding it for completeness.

#!/usr/bin/env bash

Xvfb $DISPLAY -screen $DISPLAY 1280x1024x16 &
gunicorn \
  --worker-class gevent \
  --worker-tmp-dir /dev/shm \
  --capture-output \
  --enable-stdio-inheritance \
  --bind "0.0.0.0:5000" \
  "wsgi:app" \
  --workers 1 \
  --threads 1 \
  --max-requests 1000 \
  --log-level DEBUG \

This has resolved the issue for me. Hope this helps someone :)

@minglinlu
Copy link

pip3 show undetected_chromedriver

I have the same problem with you, and everthing is updated including chrome, selenium, python3

the error is :
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:41087

During handling of the above exception, another exception occurred: Traceback (most recent call last): File "main.py", line 3, in <module> chatbot = Chatbot({ File "/home/guest/.local/lib/python3.8/site-packages/revChatGPT/ChatGPT.py", line 78, in __init__ self.get_cf_cookies() File "/home/guest/.local/lib/python3.8/site-packages/revChatGPT/ChatGPT.py", line 496, in get_cf_cookies driver.quit() UnboundLocalError: local variable 'driver' referenced before assignment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants