9

I can't do

from slack import WebClient

I get this error:

ImportError: cannot import name 'WebClient'

Have installed slack module

pip install slack

Error:

Traceback (most recent call last): File "E:\Downloads\slack-automation-master\channel_messages.py", line 3, in from slack import WebClient ImportError: cannot import name 'WebClient'

help-info.de
  • 6,695
  • 16
  • 39
  • 41
ilhaam Shaikh
  • 93
  • 1
  • 1
  • 4
  • 1
    Possible duplicate of https://stackoverflow.com/questions/57614585/python-cant-find-installed-module-slackclient-on-macos-any-suggestions – CodeRed Sep 23 '19 at 08:30
  • 1
    Possible duplicate of [Python can't find installed module slackclient on MacOs. Any suggestions?](https://stackoverflow.com/questions/57614585/python-cant-find-installed-module-slackclient-on-macos-any-suggestions) – Mark Ormesher Sep 23 '19 at 08:48
  • The PyPI package is called `slackclient`, not `slack`. So you install with: `pip3 install slackclient` – Erik Kalkoken Sep 23 '19 at 10:53
  • Do you have any file named slack.py or some other format. Just rename it. pip install slack > works fine. – Siva Sankar May 21 '21 at 13:37

5 Answers5

16

pip install slack

pip install slackclient

Should do

TOM
  • 302
  • 2
  • 8
1

uninstall slack and slackclient first: pip uninstall slack pip uninstall slackclient

then re-install, slack first

pip install slack pip install slacklient

works for versions 0.0.2 and 2.9.3 respectively

alarrain
  • 51
  • 3
0

Move to pipenv.

pip install pipenv
pipenv install -r requirements.txt
pipenv run python my_program.py
  • 1
    Hi Pradeep, welcome to stackoverflow! You are replying to an old question and this does not seem to answer the question; using pipenv does not fix the import problem described. – matz Dec 09 '20 at 21:56
0

I got this error too after an upgrade of my dependencies where I was already having slack (0.0.2) and slackclient (2.9.3)

As I was in python 3.6, I upgraded to 3.8 just to check if then it works, and BINGO, it started to work (scumbag python)

Arcones
  • 3,954
  • 4
  • 26
  • 46
-2

THere is no one solution. This is because Python version control and package dependency paths are a nightmare. What solved for me was to Sudo -H pip uninstall slack Sudo -H pip install slack

In fact the install failed because it said that the dependency was already available. Meaming, that earlier 2 versions of slack were installed. One in /usr/local/lib... folder and the other in /home/nitish/lib/...folder

What a spaghetti python is. Living up to it's name.