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

uv run fail to run pyw scripts on Mac (and probably Linux) with a confusing message #9757

Closed
ilyagr opened this issue Dec 10, 2024 · 2 comments · Fixed by #9759
Closed

uv run fail to run pyw scripts on Mac (and probably Linux) with a confusing message #9757

ilyagr opened this issue Dec 10, 2024 · 2 comments · Fixed by #9759

Comments

@ilyagr
Copy link
Contributor

ilyagr commented Dec 10, 2024

I tried reproducing the second example from https://docs.astral.sh/uv/guides/scripts/#using-gui-scripts on my Mac, and got a confusing error. I'm guessing uv tries to run a pythonw executable that doesn't exist on my system, or it's trying to run example_pyqt.pyw.py.

I think this should just work but, if not, the error message should be better.

$ uv run example_pyqt.pyw
error: Failed to spawn: `example_pyqt.pyw`
  Caused by: No such file or directory (os error 2)
$ uname -a
Darwin macaw.local 23.6.0 Darwin Kernel Version 23.6.0: Thu Sep 12 23:36:12 PDT 2024; root:xnu-10063.141.1.701.1~1/RELEASE_ARM64_T6020 arm64 arm Darwin
$ uv --version
uv 0.5.7 (Homebrew 2024-12-06)

After renaming the file to .py, everything worked (it's an impressive demo!).

@zanieb
Copy link
Member

zanieb commented Dec 10, 2024

Ah pyw is "Windows only", we can improve the error message here. Or.. just invoke the python interpreter (which I think could be correct?)

@ilyagr
Copy link
Contributor Author

ilyagr commented Dec 10, 2024

Thanks! I think either approach could work.

I also wonder whether there are other cases where uv will deceptively report "Failed to spawn x: No such file or directory" when x actually exists.

charliermarsh pushed a commit that referenced this issue Dec 10, 2024
I don't see any real reason to forbid executing these in a
cross-platform way

```
❯ echo "print('hello world')" > test.pyw
❯ uv run test.pyw
error: Failed to spawn: `test.pyw`
  Caused by: No such file or directory (os error 2)
❯ cargo run -q -- run test.pyw
hello world
```

Closes #9757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants