Hello,
I have a simple script I'm trying to run in bitbar:
#! /usr/bin/env python3
print('hello world')
When I run in bitbar, I see an error message:
env: python3: No such file or directory
This would indicate that my PATH variable doesn't contain a path to my Python 3 interpreter. But if I choose "Run in Terminal", it runs fine in the terminal, so that's not the issue.
If I change my shebang to just:
#! /usr/bin/env python
Everything works, however it's now using the crummy old Python 2.7.1 that comes installed in OSX. Setup is Imac running MAC OSX 10.12.1 (Sierra).
Btw, I'm just using 'hello world' to test, I have another script that relies on the modules installed to my Python 3 folders and not python 2, hence the script requiring Python 3.
Thank you kind sirs.
@matryer
No matter, I used this shebang from another answered issue
#!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python3
That seems to work.
To keep your script portable this works:
#!/usr/bin/env -S PATH="${PATH}:/usr/local/bin" python3
Or with some more variables
#!/usr/bin/env -S PATH="${PATH}:/usr/local/bin" PYTHONIOENCODING=UTF-8 LC_ALL=en_US.UTF-8 python3
It simply appends the new OSX default path for user binaries to the PATH. This should work for people that brew install python3 and brew link python3
...?!
Maybe I don't belong here
Most helpful comment
No matter, I used this shebang from another answered issue
#!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python3That seems to work.