profile
viewpoint

Ask questions[1.0.0b4] poetry run fails with FileNotFoundError

  • [x] I am on the latest Poetry version.

  • [x] I have searched the issues of this repo and believe that this is not a duplicate.

  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option). poetry run -vvv does not change anything about the output

  • OS version and name: Linux x86_64 (Elementary OS)

  • Poetry version: 1.0.0b4

  • Link of a Gist with the contents of your pyproject.toml file: Link (generated with poetry new)

Issue

Running poetry run without additional argument fails with

[FileNotFoundError]
[Errno 2] No such file or directory

Executing poetry run pip list for example works fine. It's just with either no argument or when the first argument is not found as an executable.

python-poetry/poetry

Answer questions mattwelke

I'm getting this error even after I run poetry install.

Steps to reproduce:

  • Create new Poetry project with poetry init.
  • Create file app.py with contents print('hello').
  • Run poetry run app.py.

Something I notice is that poetry can't run my program but using python directly can:

poetry run app.py 

  FileNotFoundError

  [Errno 2] No such file or directory

  at ~/.pyenv/versions/3.9.1/lib/python3.9/os.py:607 in _execvpe
       603│         path_list = map(fsencode, path_list)
       604│     for dir in path_list:
       605│         fullname = path.join(dir, file)
       606│         try:
    →  607│             exec_func(fullname, *argrest)
       608│         except (FileNotFoundError, NotADirectoryError) as e:
       609│             last_exc = e
       610│         except OSError as e:
       611│             last_exc = e
python app.py 
hello

EDIT:

Oh wait, I'm just stupid. I misunderstood how to use the poetry run command. Checking the docs helped me:

poetry run python app.py
hello
useful!
source:https://uonfu.com/
answerer
Matt Welke mattwelke @groupby Toronto, Canada https://mattwelke.com Back end software developer & data engineer.
Github User Rank List