I'm trying to add my python3 script to Automator using the shell /bin/bash, but keep getting the error:
"ImportError: No module named watchdog.observers”"
Which I assume is because it runs Python 2 and not 3. After searching on the internet I came up with the following./bash_profile and shebang line, but it still does not seem to work. This is what I tired in the automator:
This is what my bash_profile looks like:
And finally this is what the first lines in the Python script looks like:
And when I then run the Automator I get the following error message:
Why do I get the import error and how do I fix it?
Okay, so I solve it. In the Automator (shell /bin/bash) I did:
/Users/username/Documents/categorize_downloads.py
Before that I had change permissions on the file I wanted to run, so:
chmod 755 filename
And then finally I changed the shebang to:
#!/usr/local/bin/python3
It seems to be cases when "env python3" could be used instead, but in this case I had to remove "env".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.