AnotherJason Posted January 14 Share Posted January 14 First off, I apologize I have no idea what I'm doing. I successfully wrote a pretty simple python script that uses pyperclip. When I run it through Alfred's python3 it says "ModuleNotFoundError: No module named 'pyperclip'" I read elsewhere on these forums that it matters where pyperclip is installed so I have tried to use --target to put it in the proper place but no where I try seems to work. Currently when I use pip show pyperclip the location is -- /opt/homebrew/lib/python3.11/site-packages. Can someone ELI5 this whole situation? Link to comment
AnotherJason Posted January 14 Author Share Posted January 14 Currently running it externally through a terminal command... but that feels a little undignified don't you think? Link to comment
vitor Posted January 15 Share Posted January 15 To include a Python package with the workflow, use the --target option to set it somewhere inside the workflow’s folder and set PYTHONPATH to that path. For portability make it a relative path, not an absolute one (workflows start running from their own directory). StackOverflow has other options and examples. Make sure to install with /usr/bin/python3 so packages are built with the system python. See also Understanding the Scripting Environment. Link to comment
AnotherJason Posted January 15 Author Share Posted January 15 You know how sometimes you have to read the same thing multiple times to get it? I wasn't understanding PYTHONPATH For anyone in the future reading this who is as dumb as me: Click the [X] in the upper right hand corner Choose "Environment Variables" at the top Click the + Button in the lower right NAME = PYTHONPATH VALUE = (the path to your python) My current path would not work for anyone else, or on any other computer. But because this workflow is so specific to what I'm trying to do for myself, I don't plan on publishing it... Link to comment
vitor Posted January 15 Share Posted January 15 As you noted that would not work on other machines, so it is not the described solution. You either set it in your script on or the Run Script where you’re calling the Python script from, with export PYTHONPATH='path_here', replacing path_here with the relative path. You don’t touch the Workflow Environment Variables section at all. This is why it is recommended to always share a barebones version of your workflow when asking for help. I can’t really guide you more specifically because I can’t see what specifically you have done. 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