oserror when running puppeteer on raspberry pi

  • Last Update :
  • Techknowledgy :

Apparently the solution was to redirect chromium path in the code to some version of chromium you know is working. so

whereis chromium - browser

and then:

browser = await launch(headless = True, executablePath = '/usr/bin/chromium-browser') # where your chromium was, in my
case /usr/bin / ...

Suggestion : 2

Try using your chromium-browser, rather than Puppeteer's chrome which might not work on the PI's ARM architecture.,const browser = await puppeteer.launch({ executablePath: 'chromium-browser' }); ,For anyone for whom the above mentioned solution doesn't work, make sure that you have chromium installed on your RPI or install it using., The text was updated successfully, but these errors were encountered:

const browser = await puppeteer.launch({
   headless: true,
   args: ['--no-sandbox', '--disable-setuid-sandbox']
});
Error: Failed to launch chrome!
   /home/xxxx / .../node_modules/puppeteer / .local - chromium / liniux - 641577 / chrome - linux / chrome: Syntax error: word unexpected(expecting ") "
const browser = await puppeteer.launch({
   headless: true,
   executablePath: '/home/xxxx/.../node_modules/puppeteer/.local-chromium/liniux-641577/chrome-linux/chrome',
   args: ['--no-sandbox', '--disable-setuid-sandbox']
});
Error: Failed to launch chrome!spawn /
   home / xxxx / .../node_modules/puppeteer / .local - chromium / liniux - 641577 / chrome - linux / chrome ENOENT
Chromium 73.0 .3683 .75 Built on Ubuntu, running on Ubuntu 18.04

Suggestion : 3

I found that in raspbian stretch , chromium version 60 is preinstalled and chromium-headless works with command line chromium-browser --headless --disable-gpu --print-to-pdf https://www.google.com how could i use built in chromium for puppeteer? @ak239 @silverwind,Then checked that puppeteer didn’t install any browser (there shouldn’t be any “.local-chromium” or anything like that):,apt-get install chromium-browser - I tried to use this Chromium by passing executablePath as launch argument but puppeeteer just freezes without any errors or exceptions, I think that chromium-browser version is too old.,Stretch includes chromium-browser 65. sudo apt install chromium-browser chromium-codecs-ffmpeg

wget http://launchpadlibrarian.net/341807203/chromium-browser_62.0.3202.62-0ubuntu0.14.04.1204_armhf.deb
wget http://launchpadlibrarian.net/341807199/chromium-codecs-ffmpeg-extra_62.0.3202.62-0ubuntu0.14.04.1204_armhf.deb
sudo dpkg -i chromium-browser_62.0.3202.62-0ubuntu0.14.04.1204_armhf.deb
sudo dpkg -i chromium-codecs-ffmpeg-extra_62.0.3202.62-0ubuntu0.14.04.1204_armhf.deb
cat > test.js <<EOF
const puppeteer = require('puppeteer');
(async () => {
        const browser = await puppeteer.launch({executablePath: '/usr/bin/chromium-browser'});
        const page = await browser.newPage();
        await page.goto('https://example.com');
        await page.screenshot({path: 'example.png'});
        await browser.close();
})();
EOF
node test.js

For which ever version of Chromium you want to install the idea is the same just replace the example here with the files you downloaded. Also you need to install the chromium-codecs-ffmpeg package first before trying to install the actual chromium-browser package. This example is for the dev version, Chromium 65. I used the ubuntu 14 (Trusty) versions and had no issues creating images or pdfs.

wget https: //launchpad.net/~chromium-team/+archive/ubuntu/dev/+build/14258758/+files/chromium-codecs-ffmpeg_65.0.3322.3-0ubuntu0.14.04.1_armhf.deb; sudo dpkg -i chromium-codecs-ffmpeg_65.0.3322.3-0ubuntu0.14.04.1_armhf.deb

   wget https: //launchpad.net/~chromium-team/+archive/ubuntu/dev/+build/14258758/+files/chromium-browser_65.0.3322.3-0ubuntu0.14.04.1_armhf.deb; sudo dpkg -i chromium-browser_65.0.3322.3-0ubuntu0.14.04.1_armhf.deb

I used the following code in test.js (thanks @jindongh) to make sure the installed version would launch without issue, take a screen capture and save it as an image.

const puppeteer = require('puppeteer');
(async () => {
   const browser = await puppeteer.launch({
      executablePath: '/usr/bin/chromium-browser'
   });
   const page = await browser.newPage();
   await page.goto('https://example.com');
   await page.screenshot({
      path: 'example.png'
   });
   await browser.close();
})();

After trying all night, all I could get was:

$ chromium - browser--version
Illegal Instruction

The solution is just to use the chromium browser in the default repositories (version 65 on stretch raspian).

apt - get update && apt - get install chromium - browser

This worked for me (updated @Austinb with the now beta channel):

wget https: //launchpad.net/~chromium-team/+archive/ubuntu/beta/+build/14381587/+files/chromium-codecs-ffmpeg_65.0.3325.88-0ubuntu0.17.10.1_armhf.deb; sudo dpkg -i chromium-codecs-ffmpeg_65.0.3325.88-0ubuntu0.17.10.1_armhf.deb
wget https: //launchpad.net/~chromium-team/+archive/ubuntu/beta/+build/14381587/+files/chromium-browser_65.0.3325.88-0ubuntu0.17.10.1_armhf.deb; sudo dpkg -i chromium-browser_65.0.3325.88-0ubuntu0.17.10.1_armhf.deb
  1. Add to the code
const {
   CHROME_BIN
} = process.env;
const browser = await puppeteer.launch(Object.assign({}, PUPPETEER_CONFIG, {
   executablePath: CHROME_BIN
}));

Raspbian 9.4 stretch, armv7l Linux 4.14.71-v7+ puppeteer: 1.9.0 chromium-browser_71.0.3554.0-0ubuntu0.16.04.1_armhf.deb

wget https: //launchpad.net/~chromium-team/+archive/ubuntu/dev/+build/15468703/+files/chromium-codecs-ffmpeg_71.0.3554.0-0ubuntu0.16.04.1_armhf.deb && sudo dpkg -i chromium-codecs-ffmpeg_71.0.3554.0-0ubuntu0.16.04.1_armhf.deb
   wget https: //launchpad.net/~chromium-team/+archive/ubuntu/dev/+build/15468703/+files/chromium-browser_71.0.3554.0-0ubuntu0.16.04.1_armhf.deb && sudo dpkg -i chromium-browser_71.0.3554.0-0ubuntu0.16.04.1_armhf.deb

update. new links for chromium 71, working with 1.9.0

wget https: //launchpad.net/~chromium-team/+archive/ubuntu/beta/+build/15690067/+files/chromium-codecs-ffmpeg_71.0.3578.62-0ubuntu0.16.04.1_armhf.deb
   wget https: //launchpad.net/~chromium-team/+archive/ubuntu/beta/+build/15690067/+files/chromium-browser_71.0.3578.62-0ubuntu0.16.04.1_armhf.deb

Suggestion : 4

 August 13, 2022     pip, pyside, python     No comments   

I'm trying to pip install pyside to my Raspberry Pi and receive the following error:

pi @raspberrypi: / $ sudo pip install pyside
Collecting pyside
Using cached https: //files.pythonhosted.org/packages/36/ac/ca31db6f2225844d37a41b10615c3d371587677efd074db29855e7035de6/PySide-1.2.4.tar.gz
   Building wheels
for collected packages: pyside
Running setup.py bdist_wheel
for pyside...error
Complete output from command / usr / bin / python - u - c "import setuptools, tokenize;__file__='/tmp/pip-build-TXwQwt/pyside/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))"
bdist_wheel - d / tmp / tmps80BMupip - wheel - --python - tag cp27:
   Removing / tmp / pip - build - TXwQwt / pyside / pyside_package
running bdist_wheel
running build
Python architecture is 32 bit
error: Failed to find cmake.Please specify the path to cmake with--cmake parameter.

   -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Failed building wheel
for pyside
Running setup.py clean
for pyside
Failed to build pyside
Installing collected packages: pyside
Running setup.py install
for pyside...error
Complete output from command / usr / bin / python - u - c "import setuptools, tokenize;__file__='/tmp/pip-build-TXwQwt/pyside/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))"
install--record / tmp / pip - 5 BdNE7 - record / install - record.txt--single - version - externally - managed--compile:
   Removing / tmp / pip - build - TXwQwt / pyside / pyside_package
running install
running build
Python architecture is 32 bit
error: Failed to find cmake.Please specify the path to cmake with--cmake parameter.

   -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Command "/usr/bin/python -u -c "
import setuptools, tokenize;
__file__ = '/tmp/pip-build-TXwQwt/pyside/setup.py';
f = getattr(tokenize, 'open', open)(__file__);
code = f.read().replace('\r\n', '\n');
f.close();
exec(compile(code, __file__, 'exec'))
" install --record /tmp/pip-5BdNE7-record/install-record.txt --single-version-externally-managed --compile"
failed with error code 1 in /tmp/pip - build - TXwQwt / pyside /
   pi @raspberrypi: / $

There are no pyside binary wheels for Pi so you need to install a lot of prerequisites and compiles from sources:

sudo apt - get install build - essential git cmake libqt4 - dev libphonon - dev python2 .7 - dev libxml2 - dev libxslt1 - dev qtmobility - dev libqtwebkit - dev