1

I'm developing a slackbot. After importing slackclient, I got ModuleNotFoundError: No module named 'slackclient'.

I tried all the options and followed suggestions showed in the post here- Python can't find installed module ('slackclient'). By those suggestions, I installed slack but got the following error while importing WebClient.

>>> from slack import WebClient 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'WebClient' from 'slack' (<path_to _venv>/.venv/lib/python3.7/site-packages/slack/__init__.py)

I checked the slack version that seems like ok

slack         0.0.2  

Any suggestions what could I be doing wrong?

Anoop R Desai
  • 712
  • 5
  • 18
pitt
  • 25
  • 2
  • 10
  • It seems either you have not installed slackclient correct version. You can refer https://pypi.org/project/slackclient/#requirements – DimoMohit Aug 22 '19 at 17:59

4 Answers4

5

Using slackclient version 2

$ pip install slackclient --upgrade
$ pip freeze

slackclient==2.1.0

from slack import WebClient

OR, Using slackclient version 1

$ pip install slackclient==1.3.1

from slackclient import SlackClient

Arnold
  • 66
  • 4
2

there seems to be a conflict between slack versions and imports. If you are using slack >= 0.0.2 and slackclient >= 0.36.2, try this instead:

from slack.web.client import WebClient

you can check that WebClient class is defined in that directory.

alarrain
  • 51
  • 3
2

I was able to get it to work by using

from slack.web.client import WebClient
Raphael
  • 1,518
  • 2
  • 14
  • 27
1

The current version of slackclient for Python3 is 2.1.0.

To upgrade your environment run:

$ pip3 install slackclient --upgrade

You find the latest slackclient here.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • @pitt If this answer solved your question please consider marking it as solution by clicking on the checkmark next to the score. TY! – Erik Kalkoken Sep 23 '19 at 10:54