Bitbar: Problem with python 3 shebang

Created on 21 Nov 2016  路  4Comments  路  Source: matryer/bitbar

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.

Most helpful comment

No matter, I used this shebang from another answered issue

#!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python3

That seems to work.

All 4 comments

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JayBrown picture JayBrown  路  9Comments

dbuezas picture dbuezas  路  7Comments

dzg picture dzg  路  4Comments

BigPrimeNumbers picture BigPrimeNumbers  路  4Comments

JayBrown picture JayBrown  路  11Comments