benjamin74 Posted June 15, 2016 Share Posted June 15, 2016 Hello guys, Running v3. Question : My workflow needs a Python library that isn't shipped with OSX... as I'm using my workflows on multiple machines I'd rather NOT have to install various python packages everywhere. Now I couldn't find any information on where to add python libraries that are to be used for a custom workflow... Any information on this ? Thanks, Cheers, Link to comment
benjamin74 Posted June 15, 2016 Author Share Posted June 15, 2016 Ohh and I also didn't find how to call the imported Python libraries. e.g. I'm trying to add tld library: https://pypi.python.org/pypi/tld#downloads Once downloaded I get all these files here : Now : 1) What files/folder should I move to my workflow (and where is my workflow folder in which I must paste these files/folder) 2) What do I need to do to be able to use basic commands using the Python Library I've added, e.g.: from tld import get_tld from tld.utils import update_tld_names update_tld_names() print get_tld("{query}") Thanks !! Link to comment
deanishe Posted June 15, 2016 Share Posted June 15, 2016 Best thing to do with Python libraries is to install them in the workflow directory alongside info.plist.Right-click on your workflow in Alfred Preferences and select Open in Terminal.Now you're in the workflow directory. This is the working directory when Alfred runs your workflow, and you can import any Python packages/modules in it directly.So, in Terminal just run: pip install -U --target=. tld [<package2>...] Note: That probably won't work if your pip is installed in a Homebrew Python due to a pip bug. You need to install pip in the system Python. Link to comment
Stephen_C Posted May 14 Share Posted May 14 See this Alfred help page: Installing Dependencies. Stephen Link to comment
vitor Posted May 17 Share Posted May 17 On 5/14/2024 at 9:14 AM, Textdriven said: Is this still the recommended way? More specifically, use the --target option and set PYTHONPATH. StackOverflow has other options. Make sure to install with /usr/bin/python3 so packages are built with the system python. 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