python-slack-sdk: ImportError: No module named slackclient
- I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
- I’ve read and agree to the Code of Conduct.
- I’ve searched for any related issues and avoided creating a duplicate issue.
Description
Reproducible in:
- This is reproducible in the sample project. python-slackclient version: Up-to-date Python Version:2.7 OS Version: 10.12.4 (16E195)
Steps to reproduce:
Expected result:
Run slackclient
Actual result:
told me ImportError: No module named slackclient
Attachments:
from slackclient import SlackClient
from bs4 import BeautifulSoup
import urllib2
import requests
import re
I just import the required package but it told me not found slackclient I tried install and uninstall and then re-install but not working Mac system version : 10.12.4 (16E195)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 19 (3 by maintainers)
If you look in the folder where all of your packages are you can see the slackclient actually installed a folder called
slackbot
and notslackclient
. If you dofrom slackbot.slackclient import SlackClient
it should resolve the issue@NathanSepulveda 👋 I may be able to help! ⛑ It seems like you’re attempting to use the name
slackclient
in yourimport
statement. While you install the packageslackclient
, the actual module name isslack
! For example:Let me know if that does/doesn’t work. 😊
@NathanSepulveda Oh, it seems you’re using the old version of the package now. That is, for some reason you have v1 installed. In v1, the module was also named
slackclient
and featured a class namedSlackClient
. In v2, the module name changed toslack
, (but the package is still namedslackclient
) and the client was split intoWebClient
andRtmClient
.Just to be clear as crystal, v2 of this package is meant to be installed as
slackclient
but used asslack
. That is, you could do (kind of[1]):And then this code would work:
The names are different depending on where you use it, but point to the same thing. Sorry about that confusion 😕. Even though you install a package named
slackclient
, you import a module namedslack
… in v2.It looks like you had v2 installed, but were trying to import it with the wrong name. Somehow, you installed v1 of this package and are using that now.
How do I upgrade?
Take a peek at this solution I wrote for upgrading your package install to v2. After upgrading your
slackclient
package to v2, you’ll be able toimport slack
and use theWebClient
.Notes
[1]: Only applies to fresh installs. If you try to
pip3 install
a package you have installed,pip3
will skip it, even if it’s outdated.@GFBryson the pip command you are using sounds like it is installing to a different interpreter than you are importing from. try installing with
python -m pip install slackclient
orpython3 -m pip install slackclient
It may have showing error because of version dependency install required version like
$ pip install slackclient==1.3.2
check with these kinds, Thanks AnywaysMake following changes from slack import WebClient slack_client=WebClient(your_token)
it works !! Thanks
So I’ve installed slackclient with the pip command listed above and python still can’t find it… I’m super confused as to why. if I use the pip command again it says all the requirements are already resolved. Any ideas?
@clavin Thanks for the help and thorough explanation!