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

Reloader using wrong python executable #1580

amcgavin opened this issue Jun 5, 2019 · 3 comments

Reloader using wrong python executable #1580

amcgavin opened this issue Jun 5, 2019 · 3 comments


Copy link

amcgavin commented Jun 5, 2019

Python version: 3.6.5
Werkzeug version: 0.15.4

The change made as a result of this PR, #1242, causes inconsistent behaviour when specifying how a script should be run.

sys.executable might not (validly) equal the file's shebang.
For example, a developer might want to test their program with a different version of python, or run under a different environment to where the program would be deployed.

The biggest use case is running a script with a debugger, as seen with this issue: #1493

The developer shouldn't be forced to change shebangs or to change the execute permissions of the file to make it work.

In summary, if an executable is specified, then that executable should be used; regardless of the file's shebang.

Since the intention was for this to work with NixOS, I propose that if the functionality is to remain then it should be exclusive to NixOS (where it was pointed out on the PR that it seems to be a problem with the OS), similarly to Windows.

Copy link

davidism commented Jun 5, 2019

Remove the interpreter line and only use the desired python commands. Or use tox to configure venvs for tests, where python will always refer to the correct interpreter.

Copy link

amcgavin commented Jun 6, 2019

I agree that there are ways to set this up so that it works correctly.

As mentioned in this issue, #1482 , the solution to make it work on NixOS doesn't feel right over all.

The file being executed shouldn't have the final say on how it should be executed.

I'm happy to open a PR, but at this stage I don't know how to satisfy all users without adding in an additional option.

Copy link

I also encountered this issue while trying to upgrade. In my case, I have a main script that starts with #!/usr/bin/env python. Until werkzeug 0.15, I could run it with either of these:

source venv/bin/activate
./ ...
venv/bin/python ...

Both were equivalent. After #1242, this is no longer possible.

About the suggested fixes, tox doesn't fit because I don't have multiple venvs, and chmod -x would fix the second way but break the first way. Also, the app doesn't have a (just requirements.txt) so I can't use entry_points.

@davidism davidism added this to the 0.15.5 milestone Jul 15, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants