poetry: [1.0.0b4] poetry run fails with FileNotFoundError
-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 22
- Comments: 29 (4 by maintainers)
I’m getting this error even after I run
poetry install
.Steps to reproduce:
poetry init
.app.py
with contentsprint('hello')
.poetry run app.py
.Something I notice is that poetry can’t run my program but using python directly can:
EDIT:
Oh wait, I’m just stupid. I misunderstood how to use the
poetry run
command. Checking the docs helped me:it would be awfully nice if poetry told you to run
poetry install
or something instead of just FileNotFoundErrorSame problem here using
1.0.10
on Ubuntu 20.04.results in
while
poetry run python
orpoetry run pip
works.Related to #2741.
I also getting this error after renaming the parent dir. And it resolved by removing .venv dir and executing
poetry install
This was immensely helpful. I’d misread the instructions too
no, I don’t know where this changed. Try with the latest beta 1.2.0b2.
On more recent versions of poetry you will see this:
which is a more helpful error message
I’m sorry. I was mistaken. I intended to say that I removed .venv dir, after that I executed
poetry install
and I resolved itSome of the UX issues around
run
have already been fixed onmaster
:I’ve filed #5243 to address the remaining cryptic
FileNotFoundError
when an executable isn’t foundIn terms of the error message, it is raised during the call to
os.execvpe
. The reason the directory in the message is so weird in every case is because it is always the last path in the system path.I think that the output of
poetry run <command>
could be much improved if it were to produce the same output that would appear if you ranpoetry shell
followed by<command>
in the subshell. Running a nonexist command withinpoetry shell
returns (on Ubuntu 20.04)which is kind of result you’d expect in this situation. I’ve looked into this a little and am not sure on the implementation details, but will create a PR if I come up with something I’m satisfied with.
I have this issue too.
$ cat /etc/os-release
$ poetry --version
This doesn’t work:
$ poetry run "echo hello"
$ poetry run --help
This works:
$ poetry run echo hello