Stratocumulus Posted October 30, 2019 Posted October 30, 2019 Hello, I have a Python script which uploads some files. It outputs a few messages to the console when running. I've added the PATH to its location in .bash_profile and so I can run it from anywhere just by typing the name (I have also removed the .py extension to make that easier). I'd like to be able to run it using an Alfred keyword. I've created a blank workflow, added a keyword input and connected a Run Script action to it. I've selected "Exernal Script" and entered the name. This didn't work, so I modified the "Script File" field to include the full path to the file. This made the actual text contents of the script appear in the window of the Script Action, but the action still doesn't do anything. What am I doing wrong? Thanks. (macOS 10.14.6 BTW)
deanishe Posted October 30, 2019 Posted October 30, 2019 1 hour ago, Stratocumulus said: What am I doing wrong? We can't really tell you why a workflow we've never seen isn't working, especially not with a problem description of "doesn't do anything". Use Alfred's debugger. There's quite likely a useful error message in there. Also bear in mind that Alfred doesn't load your shell configuration files and doesn't share your shell environment. If you script depends on anything configured in your dotfiles, it won't work in Alfred. If you'd like our help, please upload your workflow and script somewhere and post links, so we can have a look for ourselves.
Stratocumulus Posted October 30, 2019 Author Posted October 30, 2019 OK, thank you for the Debugger tip, I had never used that before. It certainly helped. I just had to replace this from the beginning of my script: #!/usr/bin/env python3 With this: #!/usr/local/bin/python3.7 Anyway, turns out what I really wanted was the Terminal Command Action anyway, not Run Script. All is well now. Thanks.
jbreeden Posted November 25, 2019 Posted November 25, 2019 @Stratocumulus Thanks, this solved my problem as well. Any idea why `env` doesn't get the job done here? That is what I'm accustomed to using.
deanishe Posted November 26, 2019 Posted November 26, 2019 22 hours ago, jbreeden said: Any idea why `env` doesn't get the job done here? env only runs programs on PATH, and the entire problem here was that the program isn't on PATH. Alfred doesn't use the same environment as your shell because it isn't run from your shell, so if your program isn't in /bin or /usr/bin, it must be called by its full path, not just its name, from within Alfred (and other Mac apps).
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now