2 ms·
#!/usr/bin/python This is sometimes what you want, but it will always look at this exact path, and won't play nicely with virtualenv/conda. #!/usr/bin/env
by yongjik 5y ago
#!/usr/bin/python
This is sometimes what you want, but it will always look at this exact path, and won't play nicely with virtualenv/conda.
#!/usr/bin/env python
This works - it will use Python found in $PATH. Unfortunately you can't add any more parameters to the interpreter.
The contraption I wrote allows adding arbitrary parameters - I was burnt one too many times by Python silently buffering my debug messages, so I use it to always add "-u".
- emi2k01 5y agoReading `man env` in Linux shows that you can use: #!/usr/bin/env -S python $ARGS For example: #!/usr/bin/env -S python -i print("Entering interactive mode...") I'm not sure if it works in other OS.