Jump to content

Accessing A 3rd-Party Python Library Within Workflow


Recommended Posts

Hey, this has been addressed a few times but being something of a simpleton that's making it up as he goes along I haven't been able to find an answer that I understand.

 

I'm trying to create a workflow that will run a python command that deletes all messages from bots in a Slack channel. To do this I've installed 'slack-cleaner' through Python, and it works fine within Terminal. The problem is that when I try to run that in a script in an Alfred workflow, it says "line 1: slack-cleaner: command not found".

 

I looked through a few posts on here and found a response from @deanishe that suggested I need to install the slack-cleaner library into my workflow. So, I right-clicked the workflow, opened in terminal and used the command he suggested in this other thread which was pip3 install --target . slack-cleaner. That seemed to work as I was then able to see the library in my workflow, but it still says it can't find the slack-cleaner command when I run it. 

 

I am very mildly knowledgeable, verging on idiocy so it's very likely I have no idea what I'm doing and haven't understood the suggestions correctly, but any advice would be greatly appreciated. 

 

Thanks!

 

If it helps, the code I'm trying to run is below, with essential info redacted.

 

slack-cleaner --token <TOKEN> --message --group <GROUPNAME> --bot --perform --as_user

 

Link to post
6 hours ago, BananimusPrime said:

That seemed to work as I was then able to see the library in my workflow, but it still says it can't find the slack-cleaner command when I run it.

 

Those instructions only apply to libraries, not commands.

 

Instead of just calling "slack-cleaner", use the full path to the command, e.g. "/usr/local/bin/slack-cleaner"

Link to post

Well, running pip3 install --target . slack-cleaner also installed the slack-cleaner command in the bin subdirectory of your workflow. From a workflow script, you’d run it with ./bin/slack-cleaner.

 

That would be the right way to go if you want to distribute the workflow. But if it's just for personal use, it's better to use the system-wide copy so you don't have two versions to keep updated.

Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...