Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Cannot launch chromium #43

Closed
HuberTRoy opened this issue Mar 9, 2018 · 6 comments
Closed

Cannot launch chromium #43

HuberTRoy opened this issue Mar 9, 2018 · 6 comments

Comments

@HuberTRoy
Copy link
Contributor

HuberTRoy commented Mar 9, 2018

Background:

My OS is Windows 7 64bit.

I downloaded chromium at GitHub because I cannot access https://storage.googleapis.com/chromium-browser-snapshots. I also put it into C:\Users\Administrator\.pyppeteer\local-chromium\533271\chrome-win32.

chromium version is 66.0.3336.0.

When I first run the example code:

import asyncio
from pyppeteer import launch

async def main():
    browser = launch()
    page = await browser.newPage()
    await page.goto('http://example.com')
    await page.screenshot({'path': 'example.png'})
    await browser.close()

asyncio.get_event_loop().run_until_complete(main())

I got an UnicodeDecodeError(because it contains Chinese) so I also changed 'UTF-8' to 'GBK' at launch.py:

msg = self.proc.stdout.readline().decode()

to

msg = self.proc.stdout.readline().decode(`GBK`)
print(msg)

Issue

I executed the example code again and got nothing.
It was pending until I kill the process chrome.exe.
I printed msg and got these information:

[0309/215247.680:ERROR:network_change_notifier_win.cc(157)] WSALookupServiceBegin failed with: 10108

[0309/215247.696:ERROR:gpu_process_transport_factory.cc(1019)] Lost UI shared context.

[0309/215247.712:ERROR:tcp_socket_win.cc(272)] CreatePlatformSocket() returned an error: 无法加载或初始化请求的服务提供程序。(Unable to load or initialize the requested service provider) (0x277A)

[0309/215247.712:WARNING:net_errors_win.cc(119)] Unknown error 10106 mapped to net::ERR_FAILED

[0309/215247.712:ERROR:tcp_socket_win.cc(272)] CreatePlatformSocket() returned an error: 无法加载或初始化请求的服务提供程序。(Unable to load or initialize the requested service provider) (0x277A)

[0309/215247.712:WARNING:net_errors_win.cc(119)] Unknown error 10106 mapped to net::ERR_FAILED

[0309/215247.712:ERROR:devtools_http_handler.cc(249)] Cannot start http server for devtools. Stop devtools.
  1. It will be pending forever.
  2. What could I do so I can use pyppeteer?

Thank your response.

@CDBridger
Copy link
Contributor

CDBridger commented Mar 11, 2018

I too have the same problem! - Windows 10 x64

[18628:16220:0312/103221.488:ERROR:network_change_notifier_win.cc(157)] WSALookupServiceBegin failed with: 10108

[18628:5808:0312/103221.530:ERROR:tcp_socket_win.cc(272)] CreatePlatformSocket() returned an error: The requested service provider could not be loaded or initialized. (0x277A)

[18628:5808:0312/103221.530:ERROR:tcp_socket_win.cc(272)] CreatePlatformSocket() returned an error: The requested service provider could not be loaded or initialized. (0x277A)

[18628:5808:0312/103221.530:ERROR:devtools_http_handler.cc(249)] Cannot start http server for devtools. Stop devtools.

[18628:16220:0312/103224.064:ERROR:gpu_process_transport_factory.cc(1019)] Lost UI shared context.

After last line above it then freezes in the next loop at line 129 in launcher.py ->
msg = self.proc.stdout.readline().decode()

EDIT:

[0312/113148.186:ERROR:network_change_notifier_win.cc(157)] WSALookupServiceBegin failed with: 10108

[0312/113148.188:ERROR:gpu_process_transport_factory.cc(1019)] Lost UI shared context.

[0312/113148.190:ERROR:tcp_socket_win.cc(272)] CreatePlatformSocket() returned an error: The requested service provider could not be loaded or initialized. (0x277A)

[0312/113148.190:WARNING:net_errors_win.cc(119)] Unknown error 10106 mapped to net::ERR_FAILED

[0312/113148.190:ERROR:tcp_socket_win.cc(272)] CreatePlatformSocket() returned an error: The requested service provider could not be loaded or initialized. (0x277A)

[0312/113148.190:WARNING:net_errors_win.cc(119)] Unknown error 10106 mapped to net::ERR_FAILED

[0312/113148.190:ERROR:devtools_http_handler.cc(249)] Cannot start http server for devtools. Stop devtools.

Is what I get if I run in headless mode (first code block is in non headless

@miyakogi
Copy link
Owner

Could you try feat/port_by_python branch?
In that branch, pyppeteer uses web IF of chrome to find WS endpoint, instead of stdout.
Encoding problem should be fixed.

@HuberTRoy
Copy link
Contributor Author

HuberTRoy commented Mar 12, 2018

@miyakogi
Thank your response.
I have tried using feat/port_by_python branch. Encoding problem had been fixed and it has unable to use pyppeteer yet. And then I tried to solve the problem. It seems because the argument env in subprocess.Popen.

The explains in documentation is

If env is not None, it must be a mapping that defines the environment variables for the new process; these are used instead of the default behavior of inheriting the current process environment.

Note
If specified, env must provide any variables required for the program to execute. On Windows, in order to run a side-by-side assembly the specified env must include a valid SystemRoot.

In the source of launcher.py If do not pass env argument, it will be setting {}.

env = self.options.get('env', {})

so, I set it to None and it worked.

env = self.options.get('env', None)

@CDBridger
It worked for me. You could try this.

miyakogi added a commit that referenced this issue Mar 12, 2018
Windows requires env var of sys root to launch chrome.
When Popen get `env=None` use same env var as python process.
@miyakogi
Copy link
Owner

Great thanks for fixing problem!
I fixed like that both on dev and on feat/port_by_python branches.

@CDBridger
Copy link
Contributor

Appears to have worked for me too!

@miyakogi
Copy link
Owner

feat/port_by_python branch is now merged to dev branch and deleted.
Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants