ChatGPT icon indicating copy to clipboard operation
ChatGPT copied to clipboard

[BUG] Having an error after "Spawning browser"

Open kingsman1960 opened this issue 2 years ago • 6 comments

Description So after "Spawning browser" appears, the message came out with it.

Steps to Reproduce Input:

from revChatGPT.ChatGPT import Chatbot

chatbot = Chatbot({
  "session_token": "<eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..~~ **Erased due to the token**>"
}) # You can start a custom conversation

response = chatbot.ask("What is TFEU?", conversation_id=None, parent_id=None) # You can specify custom conversation and parent ids. Otherwise it uses the saved conversation (yes. conversations are automatically saved)

print(response)

Expected behavior Getting the response regarding the question.

Output

Spawning browser...
DEBUG:pyChatGPT:Updating session...
DEBUG:pyChatGPT:Failed to update session: Message: no such window: target window already closed
from unknown error: web view not found
  (Session info: chrome=109.0.5414.120)
Stacktrace:
Backtrace:
	(No symbol) [0x00916643]
	(No symbol) [0x008ABE21]
	(No symbol) [0x007ADA9D]
	(No symbol) [0x0078EF6A]
	(No symbol) [0x00803AAB]
	(No symbol) [0x008161B6]
	(No symbol) [0x007FFB76]
	(No symbol) [0x007D49C1]
	(No symbol) [0x007D5E5D]
	GetHandleVerifier [0x00B8A142+2497106]
	GetHandleVerifier [0x00BB85D3+2686691]
	GetHandleVerifier [0x00BBBB9C+2700460]
	GetHandleVerifier [0x009C3B10+635936]
	(No symbol) [0x008B4A1F]
	(No symbol) [0x008BA418]
	(No symbol) [0x008BA505]
	(No symbol) [0x008C508B]
	BaseThreadInitThunk [0x772500F9+25]
	RtlGetAppContainerNamedObjectPath [0x77BB7BBE+286]
	RtlGetAppContainerNamedObjectPath [0x77BB7B8E+238]

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~\anaconda3\lib\site-packages\revChatGPT\ChatGPT.py:626, in Chatbot.get_cf_cookies(self)
    625 print("Spawning browser...")
--> 626 driver = uc.Chrome(
    627     enable_cdp_events=True,
    628     options=options,
    629     driver_executable_path=self.config.get("driver_exec_path"),
    630     browser_executable_path=self.config.get("browser_exec_path"),
    631 )
    632 print("Browser spawned.")

File ~\anaconda3\lib\site-packages\undetected_chromedriver\__init__.py:411, in Chrome.__init__(self, options, user_data_dir, driver_executable_path, browser_executable_path, port, enable_cdp_events, service_args, service_creationflags, desired_capabilities, advanced_elements, service_log_path, keep_alive, log_level, headless, version_main, patcher_force_close, suppress_welcome, use_subprocess, debug, no_sandbox, **kw)
    410 else:
--> 411     browser = subprocess.Popen(
    412         [options.binary_location, *options.arguments],
    413         stdin=subprocess.PIPE,
    414         stdout=subprocess.PIPE,
    415         stderr=subprocess.PIPE,
    416         close_fds=IS_POSIX,
    417     )
    418     self.browser_pid = browser.pid

File ~\anaconda3\lib\subprocess.py:858, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    855             self.stderr = io.TextIOWrapper(self.stderr,
    856                     encoding=encoding, errors=errors)
--> 858     self._execute_child(args, executable, preexec_fn, close_fds,
    859                         pass_fds, cwd, env,
    860                         startupinfo, creationflags, shell,
    861                         p2cread, p2cwrite,
    862                         c2pread, c2pwrite,
    863                         errread, errwrite,
    864                         restore_signals, start_new_session)
    865 except:
    866     # Cleanup if the child failed starting.

File ~\anaconda3\lib\subprocess.py:1251, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
   1250 else:
-> 1251     args = list2cmdline(args)
   1253 if executable is not None:

File ~\anaconda3\lib\subprocess.py:553, in list2cmdline(seq)
    552 needquote = False
--> 553 for arg in map(os.fsdecode, seq):
    554     bs_buf = []

File ~\anaconda3\lib\os.py:818, in _fscodec.<locals>.fsdecode(filename)
    813 """Decode filename (an os.PathLike, bytes, or str) from the filesystem
    814 encoding with 'surrogateescape' error handler, return str unchanged. On
    815 Windows, use 'strict' error handler if the file system encoding is
    816 'mbcs' (which is the default encoding).
    817 """
--> 818 filename = fspath(filename)  # Does type-checking of `filename`.
    819 if isinstance(filename, bytes):

TypeError: expected str, bytes or os.PathLike object, not NoneType

During handling of the above exception, another exception occurred:

UnboundLocalError                         Traceback (most recent call last)
Input In [22], in <cell line: 3>()
      1 from revChatGPT.ChatGPT import Chatbot
----> 3 chatbot = Chatbot({
      4   "session_token": "<eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..~ **Skipped due to token** >"
      5 }) # You can start a custom conversation
      7 response = chatbot.ask("What is TFEU?", conversation_id=None, parent_id=None) # You can specify custom conversation and parent ids. Otherwise, it uses the saved conversation (yes. conversations are automatically saved)
      9 print(response)

File ~\anaconda3\lib\site-packages\revChatGPT\ChatGPT.py:91, in Chatbot.__init__(self, config, conversation_id, parent_id, no_refresh)
     86     self.session_token = config["session_token"]
     87     self.session.cookies.set(
     88         "__Secure-next-auth.session-token",
     89         config["session_token"],
     90     )
---> 91     self.get_cf_cookies()
     92 else:
     93     raise Exception("Invalid config!")

File ~\anaconda3\lib\site-packages\revChatGPT\ChatGPT.py:646, in Chatbot.get_cf_cookies(self)
    643         sleep(5)
    644 finally:
    645     # Close the browser
--> 646     driver.quit()
    647     del driver
    648     self.refresh_headers(
    649         cf_clearance=self.cf_clearance,
    650         user_agent=self.user_agent,
    651     )

UnboundLocalError: local variable 'driver' referenced before assignment

Environment Already updated to suggested version (revChatGPT[unofficial])

kingsman1960 avatar Feb 02 '23 21:02 kingsman1960

See Also:

  • https://github.com/acheong08/ChatGPT/issues/526
  • https://github.com/acheong08/ChatGPT/issues/527

0xdevalias avatar Feb 02 '23 23:02 0xdevalias

Google Chrome must be installed properly

acheong08 avatar Feb 03 '23 00:02 acheong08

Must be same version as chromedriver

acheong08 avatar Feb 03 '23 00:02 acheong08

do you solve this problem?

gnohgnailoug avatar Feb 03 '23 06:02 gnohgnailoug

No but the Official version has been fixed. Please upgrade to the latest version

acheong08 avatar Feb 03 '23 06:02 acheong08

No but the Official version has been fixed. Please upgrade to the latest version

Thanks to your reply and your work:) ! I'll try it later

gnohgnailoug avatar Feb 03 '23 06:02 gnohgnailoug