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 (
-vvvoption).poetry run -vvvdoes 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.pywith 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 runcommand. Checking the docs helped me:it would be awfully nice if poetry told you to run
poetry installor something instead of just FileNotFoundErrorSame problem here using
1.0.10on Ubuntu 20.04.results in
while
poetry run pythonorpoetry run pipworks.Related to #2741.
I also getting this error after renaming the parent dir. And it resolved by removing .venv dir and executing
poetry installThis 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 installand I resolved itSome of the UX issues around
runhave already been fixed onmaster:I’ve filed #5243 to address the remaining cryptic
FileNotFoundErrorwhen 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 shellfollowed by<command>in the subshell. Running a nonexist command withinpoetry shellreturns (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 --versionThis doesn’t work:
$ poetry run "echo hello"$ poetry run --helpThis works:
$ poetry run echo hello