I'm running Windows 10 and I have been using an Ubuntu Linux distro under the Windows Linux Subsystem.
I want to be able to use Chrome.exe or google-chrome to run headless and take screenshots, generate pdfs etc... as part of library calls, but can't see to do that (e.g. to use jupyter_to_medium library launches chrome in the background to take screenshot).
I have tried multiple things to debug it with google-chrome independently of the library or programme I'm using.
Here's what I've tried:
I can launch Chrome (Windows executable) via the Ubuntu terminal, having redirected it to the Windows executable:
/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe
When I do that, a new tab opens in my Windows Chrome browser so no issues here.
When I try to use google-chrome
headless in ubuntu terminal I get MULTIPLE ISSUES e.g.
2a) Trying to get a screenshot - FAILs showing Network service crashed, restarting service
endless loop - had to CTRL^C to stop it
(base) etzimopoulos@DESKTOP-HI9P6E4:~$ google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
[0626/055458.471044:ERROR:udev_watcher.cc(61)] Failed to enable receiving udev events.
[0626/055458.612113:ERROR:network_service_instance_impl.cc(262)] Network service crashed, restarting service.
[0626/055458.696014:ERROR:network_service_instance_impl.cc(262)] Network service crashed, restarting service.
...
2b) Trying to get a screenshot using a different parameters --no-sandbox --disable-setuid-sandbox
, getting different error this time.
$ sudo google-chrome --no-sandbox --disable-setuid-sandbox --headless --screenshot https://www.chromestatus.com/
[0626/061854.348849:ERROR:udev_watcher.cc(61)] Failed to enable receiving udev events.
[0626/061855.311675:ERROR:platform_shared_memory_region_posix.cc(46)] Descriptor access mode (0) differs from expected (2)
[0626/061855.312483:WARNING:crash_handler_host_linux.cc(366)] Could not translate tid - assuming crashing thread is thread group leader; syscall_supported=0
[0626/061855.474617:WARNING:crash_handler_host_linux.cc(366)] Could not translate tid - assuming crashing thread is thread group leader; syscall_supported=0
--2020-06-26 06:18:55-- https://clients2.google.com/cr/report
Resolving clients2.google.com (clients2.google.com)... 216.58.210.46, 2a00:1450:4009:800::200e
Connecting to clients2.google.com (clients2.google.com)|216.58.210.46|:443... connected.
HTTP request sent, awaiting response... [0626/061855.655013:ERROR:headless_shell.cc(399)] Abnormal renderer termination.
429 Too Many Requests
2020-06-26 06:18:55 ERROR 429: Too Many Requests.
Unexpected crash report id length
Failed to get crash dump id.
Report Id: ```
Trying to run the Windows executable Chrome.exe with same parameters, seems to run but not screenshot is being taken (no new files in my directory)
Trying to run google-chrome
without elevated privilages in WSL I get a different error:
google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/ Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Permission denied Failed to generate minidump.Illegal instruction (core dumped)
Any help or direction would be hugely appreciated. My other option would be to run a VM on windows 10 with native Linux UI and terminal, which would probably work.
But is there a way to have it all setup in WSL?
Thank you.
Try this (tested in wsl2)
In your wsl2 ubuntu console enter the following commands:
#install packages
sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4 fonts-liberation
#get latest chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
#install it
sudo apt install ./google-chrome-stable_current_amd64.deb
#test a screenshot
google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With