Reticulate: pyppeteer OSError: [WinError 6] The handle is invalid

Created on 9 Jun 2019  路  4Comments  路  Source: rstudio/reticulate

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

Most helpful comment

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.

All 4 comments

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

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.

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

Having the same problem right now

Was this page helpful?
0 / 5 - 0 ratings