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

_winapi.CreateProcess FileNotFoundError: [WinError 2] #11

Open
cheditx opened this issue Jan 23, 2025 · 2 comments
Open

_winapi.CreateProcess FileNotFoundError: [WinError 2] #11

cheditx opened this issue Jan 23, 2025 · 2 comments
Labels
question Further information is requested

Comments

@cheditx
Copy link

cheditx commented Jan 23, 2025

Platform

Windows

Steps to Reproduce

the code i used

import aiopytesseract
import asyncio

async def main():

    test = await aiopytesseract.image_to_string("img_1.png")
    print(test)

asyncio.run(main())

Seems like windows api can't run a process (the image has been found by the library)

Expected Result

not crashing

Actual Result

Traceback (most recent call last):
  File "C:\Users\chris\Documents\Programs\JetBrains\pythonProject1\main.py", line 9, in <module>
    asyncio.run(main())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\chris\Documents\Programs\JetBrains\pythonProject1\main.py", line 6, in main
    test = await aiopytesseract.image_to_string("img_1.png")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\chris\Documents\Programs\JetBrains\pythonProject1\.venv\Lib\site-packages\aiopytesseract\commands.py", line 236, in _
    image_text: bytes = await execute(
                        ^^^^^^^^^^^^^^
  File "C:\Users\chris\Documents\Programs\JetBrains\pythonProject1\.venv\Lib\site-packages\aiopytesseract\base_command.py", line 76, in _
    response: bytes = await execute(
                      ^^^^^^^^^^^^^^
  File "C:\Users\chris\Documents\Programs\JetBrains\pythonProject1\.venv\Lib\site-packages\aiopytesseract\base_command.py", line 120, in _
    proc = await asyncio.wait_for(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\tasks.py", line 489, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\subprocess.py", line 223, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 1694, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\windows_events.py", line 399, in _make_subprocess_transport
    transp = _WindowsSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\windows_events.py", line 921, in _start
    self._proc = windows_utils.Popen(
                 ^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\windows_utils.py", line 153, in __init__
    super().__init__(args, stdin=stdin_rfd, stdout=stdout_wfd,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] Impossibile trovare il file specificato
@amenezes
Copy link
Owner

@cheditx,

Could you try testing the shared code using some sample data available in the tests/samples directory? For example:

import aiopytesseract
import asyncio

async def main():

    test = await aiopytesseract.image_to_string("tests/samples/file-sample_150kB.png")
    print(test)

asyncio.run(main())

# Expected output:
# Lorem ipsum
#
# Lorem ipsum dolor sit amet, consectetur adipiscing
# elit. Nunc ac faucibus odio.

@amenezes amenezes added the question Further information is requested label Jan 27, 2025
@cheditx
Copy link
Author

cheditx commented Feb 8, 2025

@cheditx,

Could you try testing the shared code using some sample data available in the tests/samples directory? For example:

import aiopytesseract
import asyncio

async def main():

test = await aiopytesseract.image_to_string("tests/samples/file-sample_150kB.png")
print(test)

asyncio.run(main())

Expected output:

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing

elit. Nunc ac faucibus odio.

Same problem

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

No branches or pull requests

2 participants