Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem running script in Devonthink #11

Open
pickleton89 opened this issue Feb 5, 2022 · 12 comments
Open

Problem running script in Devonthink #11

pickleton89 opened this issue Feb 5, 2022 · 12 comments

Comments

@pickleton89
Copy link

I have downloaded ZOWIE from your site and installed it and works fine running from the command line. I am using python 3.9. I also have implanted the Devonthink rules that you list. The 'Run Zowie on newly indexed PDF.applescript' scrript, throws an error within Devonthink saying that I have python 3.8. Don't understand why it runs at command line but not in the script. Possible has something to do with the path, but not sure. Any thoughts? Thanks in advance for your help.

@mhucka
Copy link
Owner

mhucka commented Feb 9, 2022

When AppleScript executes an external shell command, it does not respect any shell PATH environment variables you may have set in your .profile/.bashrc/.cshrc/etc. file (whatever it may be, depending on what shell you are using). So, when you test something in a terminal shell, it's possible that the command search path used by your shell is not the same as what AppleScript uses. This means a command executed from AppleScript may not find a program installed on your computer, or it may find a different version of a program if there's more than one on your computer. In the current case, it sounds like AppleScript on your computer is finding the Python interpreter /usr/bin/python3, which on macOS Catalina and later, is version 3.8. You probably have installed Python 3.9 somewhere else, and so in your shell, you're getting 3.9. Unfortunately, since AppleScript frustratingly doesn't respect your shell's path settings, it doesn't find that particular copy of Python even though your shell does.

In a recent update to the DEVONthink AppleScript code, I tried to work around this problem by explicitly setting $PATH in the shell script invocation. You can see this around line 35 in this version.

Here are some possible things to try:

  1. If your Python 3.9 installation is in /usr/local/bin or you are using pipx (which puts things in ~/.local), then the new version of the AppleScript code should work. If you got an older version, try updating the code to that latest version of the script.
  2. If your Python 3.9 installation is somewhere other than those 2 locations, copy the new version of the script but also change the line that involves setting the shell PATH environment variable. Change it to add the directory where you have installed Python 3.9. If you know what that is and you know shell syntax, this will make sense; if not (and that's fine! we're getting into ridiculously wonky stuff here), tell me the result of typing the following command in a shell on your computer: which python3. I'll reply back with instructions for how to change line 35 of that AppleScript code.

@pickleton89
Copy link
Author

Thanks so much for getting back to me. I used the 'this version' script and tried and still got the same error. I ran the 'which python3' command and this was the output: /Users/jeffkiefer/miniconda3/bin/python3
I added this to that line in the script:
"PATH=$PATH:$HOME/miniconda3/bin/python3" & " zowie -s -q " & quoted_path
This returned a sh: zowie: command not found
I am sure I am not putting in the correct syntax.

@mhucka
Copy link
Owner

mhucka commented Feb 9, 2022

Close: remove "python3" -- the path needs to be to a directory, like this:

"PATH=$PATH:$HOME/miniconda3/bin" & " zowie -s -q " & quoted_path

Also, it may be a good idea to check that zowie exists in /Users/jeffkiefer/miniconda3/bin/, i.e., check for the existence of /Users/jeffkiefer/miniconda3/bin/zowie. If you installed it via pip, it should have ended up there, but you never know ...

@pickleton89
Copy link
Author

pickleton89 commented Feb 9, 2022 via email

@mhucka
Copy link
Owner

mhucka commented Feb 9, 2022

I'm not sure if there was a question in your last reply.

Is it working now?

@pickleton89
Copy link
Author

pickleton89 commented Feb 9, 2022 via email

@mhucka
Copy link
Owner

mhucka commented Feb 9, 2022

Sorry about this, but your last sentence contains contradictory statements: "it working" but also "wrong version of python", and I can't figure out what that means. Can you clarify?

@pickleton89
Copy link
Author

pickleton89 commented Feb 9, 2022 via email

@mhucka
Copy link
Owner

mhucka commented Feb 10, 2022

This is a weird error. How did you install Zowie?

Edit: I know you wrote "I have downloaded ZOWIE from your site", but which version of Zowie? Prebuilt-binary (and if so, which one) or via pip, or something else?

@pickleton89
Copy link
Author

pickleton89 commented Feb 12, 2022 via email

@mhucka
Copy link
Owner

mhucka commented Feb 15, 2022

I'm not sure what "manual download" means. Can you please look at the installation section at https://github.com/mhucka/zowie/#installation and tell me exactly which one of the 4 listed approaches you followed? It matters to deducing what's going on.

@pickleton89
Copy link
Author

pickleton89 commented Feb 16, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants