Search code examples
pythonbashpython-poetryfilenotfounderror

poetry run worker.py | FileNotFound [Errno 2] No such file or directory: b'/snap/bin/worker.py'


I execute the below command, in the same working directory as file worker.py:

poetry run worker.py

Terminal:

me@LAPTOP-G1DAPU88:~/.ssh/workers-python/workers/composite_key/compositekey$ poetry run worker.py 

  FileNotFoundError

  [Errno 2] No such file or directory: b'/snap/bin/worker.py'

  at /usr/lib/python3.8/os.py:601 in _execvpe
       597│         path_list = map(fsencode, path_list)
       598│     for dir in path_list:
       599│         fullname = path.join(dir, file)
       600│         try:
    →  601│             exec_func(fullname, *argrest)
       602│         except (FileNotFoundError, NotADirectoryError) as e:
       603│             last_exc = e
       604│         except OSError as e:
       605│             last_exc = e
me@LAPTOP-G1DAPU88:~/.ssh/workers-python/workers/composite_key/compositekey$ ls
 Citizenship.csv                   __pycache__                 dagster.yaml   pytest.ini                  simulate_alien_dict.py   tasks.py
"Gordian Algorithms' Times.xlsx"   config.yaml                 data           run_pipeline.yaml           simulate_data.ipynb      tests
 __init__.py                       currency_symbols_map.json   modules        simulate_alien_dict.ipynb   simulate_data.py         worker.py

Clearly, we see the file is there (bottom-right).


Questions

  • Why is this an issue caused?
  • How would you resolve this issue, in future?

Please let me know if there's anything else I should add to post


Solution

  • poetry run means "run the following command in the venv managed by poetry".

    So the correct way of using it in your case is: poetry run python worker.py