ChatGPT icon indicating copy to clipboard operation
ChatGPT copied to clipboard

Adding the --headless option.

Open ArjunSahlot opened this issue 2 years ago • 6 comments

Is your feature request related to a problem? Please describe. I am trying to run this on a server, but it doesn't work on the server when --headless is disabled.

Describe the solution you'd like Adding the --headless option to Chrome Options should help fix this.

Additional context I tried adding headless mode on a fork, but then a new problem arises, no cookies. I am not able to solve this problem and that's where I would like you help.

ArjunSahlot avatar Dec 31 '22 23:12 ArjunSahlot

I also run this on a server, here's my solution to the problem: https://github.com/acheong08/ChatGPT/discussions/396

But, of course, it's a workaround. Headless option would be nice.

zahrevsky avatar Dec 31 '22 23:12 zahrevsky

Thanks for the help!

My issue is slightly different though:

Spawning browser...
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/revChatGPT/ChatGPT.py", line 401, in get_cf_cookies
driver = uc.Chrome(
File "/opt/venv/lib/python3.8/site-packages/undetected_chromedriver/__init__.py", line 411, in __init__
browser = subprocess.Popen(
File "/nix/store/zzfhcf101498slkcfgi085jqd33rjf95-python3-3.8.16/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/nix/store/zzfhcf101498slkcfgi085jqd33rjf95-python3-3.8.16/lib/python3.8/subprocess.py", line 1585, in _execute_child
and os.path.dirname(executable)
File "/nix/store/zzfhcf101498slkcfgi085jqd33rjf95-python3-3.8.16/lib/python3.8/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 "main.py", line 10, in <module>
chatbot = Chatbot({
File "/opt/venv/lib/python3.8/site-packages/revChatGPT/ChatGPT.py", line 77, in __init__
self.get_cf_cookies()
File "/opt/venv/lib/python3.8/site-packages/revChatGPT/ChatGPT.py", line 416, in get_cf_cookies
driver.quit()
UnboundLocalError: local variable 'driver' referenced before assignment

I tried using your fix, but nothing changed.

ArjunSahlot avatar Jan 01 '23 00:01 ArjunSahlot

This is probably due to either

  1. Chrome not installed
  2. Chrome driver not installed
  3. Outdated selenium
  4. Outdated undetected_chromedriver

Check out https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues for solutions

acheong08 avatar Jan 01 '23 00:01 acheong08

@ArjunSahlot I also had this error at first. @acheong08 is right, it's about chrome and driver installation. Here's what worked for me:

  1. Check that webdriver and google-chrome versions match. Here's a guide for webdriver version selection: https://chromedriver.chromium.org/downloads/version-selection. Basically, you need to pick a driver with the same version, as your google-chrome. To check your google-chrome version: google-chrome --version
  2. Also, try to explicitly pass paths to chrome and driver executables to revChatGPT, either in code or via config file, depending on your setup. See https://github.com/acheong08/ChatGPT/wiki/Setup#config-options-optional

When I fixed this error, another one came up: "cannot connect to chrome". It is the one, described in my previous comment

zahrevsky avatar Jan 01 '23 13:01 zahrevsky

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

acheong08 avatar Jan 01 '23 18:01 acheong08

I solved this problem like this: sudo apt-get update and then sudo apt-get --only-upgrade install google-chrome-stable

SeolhwaLee avatar Jan 06 '23 15:01 SeolhwaLee