retailgeek Posted November 22, 2021 Share Posted November 22, 2021 This is probably a newby question (I'm not very familiar with the OSX Shell). I need to run a two line script in the terminal: cd /Users/jgoldberg/Dropbox/Mac/Downloads/Census python3.9 api_conn.py python3.9 was installed on my machine via anaconda and so is in a (base) environment. If I open a terminal and type those two commands, they execute as expected. But if I try to run those two commands from "Terminal Command" action in workflows, it can't find the python3.9. Any tips on how I can change the workflow to use the proper environment, or how I can chance my environment variables to make the workflow work? Thanks! -Jason Link to comment
vitor Posted November 23, 2021 Share Posted November 23, 2021 Three ways:Use the full path to your tool. Instead of python3.9, call /usr/local/bin/python3.9 (or whatever the path is). Simplest method.source your shell’s configuration file before calling your script. Example: source "${HOME}/.zshrc". Highest chance of success, but may make your code marginally slower.Set PATH before calling your python installation. Similar to 1 and gives you access to more tools. Link to comment
retailgeek Posted November 23, 2021 Author Share Posted November 23, 2021 Thanks so much Vitor. #1 worked perfectly (I'm sure 2 & 3 would have as well) . Thank you very much for quick, helpful reply! Link to comment
jeremycherfas Posted November 23, 2021 Share Posted November 23, 2021 I suspect I am having a similar problem after upgrading to a new iMac. Specifically, the workflow Copy name [1.6] has /usr/bin/python as the Language variable. $PATH does contain the paths to Python in /opt/Anaconda but workflow fails and the log shows: ```` [12:58:37.371] Copy name [1.6][Hotkey] Processing complete [12:58:37.379] Copy name [1.6][Hotkey] Passing output '' to Run Script [12:58:37.452] Copy name [1.6][Run Script] Processing complete [12:58:37.456] Copy name [1.6][Run Script] Passing output '' to Post Notification [12:58:37.457] Copy name [1.6][Run Script] Passing output '' to Copy to Clipboard ```` How might I ensure that the workflow uses the correct install of Python? Thanks. Link to comment
vitor Posted November 23, 2021 Share Posted November 23, 2021 16 minutes ago, jeremycherfas said: I suspect I am having a similar problem I wouldn’t call this a problem, Alfred does it by design. Making your Workflow mostly independent of external changes benefits you both as a Workflow developer and a Workflow user: by ensuring everyone has a similar starting point, changing the environment must be a conscious decision with clear consequences. 18 minutes ago, jeremycherfas said: Specifically, the workflow Copy name [1.6] has /usr/bin/python as the Language variable. Then that is what it will use. That’s the default on macOS. 19 minutes ago, jeremycherfas said: $PATH does contain the paths to Python in /opt/Anaconda That doesn’t matter if the Workflow is using a full path to the executable. 20 minutes ago, jeremycherfas said: but workflow fails and the log shows There’s no error there. 20 minutes ago, jeremycherfas said: How might I ensure that the workflow uses the correct install of Python? I don’t know which Workflow you’re talking about, so it’s impossible to say. Where did you get it from? You should ask this on the forum post or GitHub repo where you found the Workflow, so the creator and it’s users can see your issue and help. Link to comment
jeremycherfas Posted November 23, 2021 Share Posted November 23, 2021 OK. I'll do that. I did in fact mention the name of the workflow, as you indeed quoted. 3 hours ago, vitor said: Specifically, the workflow Copy name [1.6] has /usr/bin/python as the Language variable. Link to comment
vitor Posted November 23, 2021 Share Posted November 23, 2021 Just now, jeremycherfas said: I did in fact mention the name of the workflow, as you indeed quoted. Yes, you mentioned the name but didn’t link to it. I had no way of knowing where you got it from and I was on a (very slow) phone at the time, meaning that if I changed tabs to spend an unknown amount of time searching the web for whatever you might be mentioning, I could’ve lost what I had already written. So it was either helping with the limited information you gave, or possibly being unable to help at all. When requesting assistance, you should strive to make life easier to potential helpers. That helps you by lowering the friction needed for people to look into your issue. The higher the friction, the lower the chance other people will investigate. Link to comment
jeremycherfas Posted November 23, 2021 Share Posted November 23, 2021 Sure, and I do appreciate the time you and others here take to help us out. I have now raised an issue with the person who made the workflow, at https://github.com/mcskrzypczak/Alfred2-Workflows For my information, when you say there is no error in the log, I expected to see the content of the output between the single quotes? Is that expectation wrong? Thanks again. Link to comment
vitor Posted November 24, 2021 Share Posted November 24, 2021 9 hours ago, jeremycherfas said: Is that expectation wrong? No. In this case it should show, yes. I’m unable to reproduce your issue. Link to comment
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