Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyppeteer OSError: [WinError 6] The handle is invalid #518

Closed
athammad opened this issue Jun 9, 2019 · 6 comments · Fixed by #1458
Closed

pyppeteer OSError: [WinError 6] The handle is invalid #518

athammad opened this issue Jun 9, 2019 · 6 comments · Fixed by #1458

Comments

@athammad
Copy link

athammad commented Jun 9, 2019

Hi guys,

I have the following script that runs perfectly in python from the command line, but not when I run it from the python script in R or when I use source_python()
I keep getting the following error and I was wandering how is this possible.

OSError: [WinError 6] The handle is invalid

import asyncio
from pyppeteer import launch

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

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

Cheers

@kevinushey
Copy link
Collaborator

I also see this:

> reticulate:::py_last_error()
$type
[1] "OSError"

$value
[1] "[WinError 6] The handle is invalid"

$traceback
[1] "  File \"<string>\", line 12, in <module>\n"                                                                                                                                
[2] "  File \"C:\\Users\\kevin\\ANACON~1\\envs\\test\\lib\\asyncio\\base_events.py\", line 584, in run_until_complete\n    return future.result()\n"                             
[3] "  File \"<string>\", line 6, in main\n"                                                                                                                                     
[4] "  File \"C:\\Users\\kevin\\ANACON~1\\envs\\test\\lib\\site-packages\\pyppeteer\\launcher.py\", line 311, in launch\n    return await Launcher(options, **kwargs).launch()\n"
[5] "  File \"C:\\Users\\kevin\\ANACON~1\\envs\\test\\lib\\site-packages\\pyppeteer\\launcher.py\", line 169, in launch\n    **options,\n"                                       
[6] "  File \"C:\\Users\\kevin\\ANACON~1\\envs\\test\\lib\\subprocess.py\", line 728, in __init__\n    errread, errwrite) = self._get_handles(stdin, stdout, stderr)\n"          
[7] "  File \"C:\\Users\\kevin\\ANACON~1\\envs\\test\\lib\\subprocess.py\", line 1025, in _get_handles\n    p2cread = _winapi.GetStdHandle(_winapi.STD_INPUT_HANDLE)\n"          

$message
[1] "OSError: [WinError 6] The handle is invalid"

I wonder if it's related to this issue: https://bugs.python.org/issue26832

@iuiu34
Copy link

iuiu34 commented Jan 29, 2020

I had the same issue with sklearn2pmml (working in python-console, not in RStudio)
And was fixed adding stdin = PIPE in Popen function inside library.

@oujbih
Copy link

oujbih commented Apr 23, 2020

@iuiu1234
please can you give more detail how your actually be able to solve the problem
for example: the path of Popen function .

@favstats
Copy link

favstats commented Jun 2, 2020

Having the same problem right now

@cajasc
Copy link

cajasc commented Jul 13, 2021

I´m having the same error when running

import subprocess

subprocess.run(" ".join([r'"C:/Program Files (x86)/Renewable NRG Systems/SymPRO Desktop/SymPRODesktop.exe"']), stdout=subprocess.PIPE)

And it didn´t work with stdin=subprocess.PIPE

some help?

@kevinushey
Copy link
Collaborator

See https://stackoverflow.com/a/43606682/1342082 for a potential resolution.

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

Successfully merging a pull request may close this issue.

6 participants