Jump to content

Python3 with /bin/bash


Recommended Posts

Hi,

How can I use Python3 code in my workflows?

 

At the moment I am just trying as a test to print a string and send it to a post notification.

 

This works fine (in Python2) if I select "/usr/bin/python" and use sys.stdout.write(s). I can also use the unix command echo to print a string and send it to a notification but my Python3 shell script does nothing in Alfred, even though I can execute it perfectly fine via the terminal.

 

My Python3 shell script is very simple.

#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
print('hello')

 

Please help!

 

Thanks,

 

Halfred

Edited by halfred
Link to comment

That first line is a shebang and indicates what interpreter to use when running a script. But what you’re doing is telling it to be executed inside /bin/bash, so you already picked the interpreter. As fas as bash cares, that line is just a comment (starts with #) to be ignored.


You’ll have to save that code inside a script file and make it executable (chmod +x file). Then you’ll either call it inside /bin/bash with ./script_path, or change the Language to External Script and set the path there.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...