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?
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
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.
I was able to get it to work by using
from slack.web.client import WebClient
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.
Related
Hi I thought this would be pretty straightforwards but I can't figure it out.
It can't find binance.websockets for whatever reason even though it can find binance.client which should be part of the same package?
import config
import os
from binance.client import Client
from twisted.internet import reactor
from binance.websockets import BinanceSocketManager
Running this import code gives this error
Traceback (most recent call last):
File "/home/lucho/Documents/cryptoAPIs/binance/importconfig.py", line 6, in <module>
from binance.websockets import BinanceSocketManager
ModuleNotFoundError: No module named 'binance.websockets
To get the library I installed with pip3
pip3 install python-binance
pip3 install binance-api
The BinanceSocketManager is no longer in the websockets file. Change your import to this:
from binance.streams import BinanceSocketManager
This will fix the issue
use this " pip install python-binance==0.7.9 "
If you look into the breaking changes on version 1.0.1 they mention they changes Websockets, so that is probably what you are hitting.
I would just reinstall the latest version "pip install python-binance" and use the up to date examples on their repo:
https://github.com/sammchardy/python-binance
I'm attempting to use the example code to receive data from Azure Event Hub.
Heres the code
import os
import sys
import logging
import time
from azure.eventhub import EventHubClient, Receiver, Offset
logger = logging.getLogger("azure")
ADDRESS = "amqps://mine.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=sadfsafdljksad=<eventhub>"
But I am getting the following error when executing..
Traceback (most recent call last):
File "./recv.py", line 5, in <module>
from azure.eventhub import EventHubClient, Receiver, Offset
ImportError: cannot import name 'EventHubClient'
Any assistance will be appreciated.
I think you actually installed azure-eventhub package, version 5.0.0. But EventHubClient does not exist in 5.0.0 version, it exists in azure-eventhub package, version 1.3.3 or below.
By default, when you install the azure eventhub package for python using this command pip install azure-eventhub, it will automatically install the latest version 5.0.0. So this sentence from azure.eventhub import EventHubClient, Receiver, Offset will throw the error ImportError: cannot import name 'EventHubClient'
You can check the version of the package by open cmd -> input command pip show azure-eventhub. Screenshot as below:
There are 2 solutions:
Solution 1: keep using the 5.0.0 version, then you should re-write your code and follow the examples in this doc.
Solution 2: If you want to use the current code which includes from azure.eventhub import EventHubClient, Receiver, Offset, you should first uninstall the 5.0.0 version of azure-eventhub, then reinstall the 1.3.3 version by using this command pip install azure-eventhub==1.3.3
Using this solution works fine
reinstall the 1.3.3 version by using this command pip install azure-eventhub==1.3.3
I can't import correct Firebase package in Raspberry PI.
My code:
from firebase import firebase
db = firebase.FirebaseApplication("https://xyz.firebaseio.com/", None)
Error:
Traceback (most recent call last):
File "datastorage.py", line 1, in <module>
from firebase import firebase
firebase/__init__.py", line 14, in <module>
import python_jwt as jwt
ModuleNotFoundError: No module named 'python_jwt'
I tried to use this commands and it didn't help:
sudo pip install requests
sudo pip install python-firebase
pip install jwt
I use Python 3.7.3 and Raspbian Buster. All works on my PC but not on RPi 3B+.
I used advice from #naive.
pip install python_jwt
After that I solved another errors in that order:
pip install gcloud
pip install sseclient
pip install pycrypto
pip install requests-toolbelt
And now I see that It works. Problem was solved.
I think you need python_jwt instead of jwt. You can do:
pip install python_jwt
If you're referring to this library:
https://pyjwt.readthedocs.io/en/latest/
Then you need to install like this:
pip install PyJWT
And afterwards this will work:
import jwt
I am relatively new to Python and I am stuck on something which is probably relatively easy to resolve.
I have installed the following packages:
pip install --upgrade google-api-python-client
pip install --upgrade google-cloud
pip install --upgrade google-cloud-vision
In my Python file I have:
import cv2
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
...etc...
And this gives me the error:
Traceback (most recent call last):
File "test.py", line 6, in <module>
from google.cloud import vision
ImportError: No module named 'google.cloud'
What am I missing and where should I look (logs?) to find the answer in the future.
PS:
Pip installs of google-cloud and google-cloud-vision have the output:
Cannot remove entries from nonexistent file /Users/foobar/anaconda/lib/python3.5/site-packages/easy-install.pth
UPDATE:
Running pip freeze doesn't show the packages to be installed...
I had a similar problem. Adding "--ignore-installed" to my pip command made it work for me.
This might be a bug in pip - see this page for more details: https://github.com/pypa/pip/issues/2751
You need to download and install the google-cloud-sdk. Follow this link https://cloud.google.com/sdk/docs/
try this :
from google.cloud.vision import *
I'm trying to run a python program with twitter module.
I installed the twitter and json packages via:
pip install twitter
pip install simplejson
While running the program I'm getting error in both python 2 and python 3 version.
My code:
try:
import json
except ImportError:
import simplejson as json
import twitter
from twitter import Twitter, OAuth, TwitterHTTPError, TwitterStream
Error:
Traceback (most recent call last):
File "Untitled.py", line 5, in <module>
import twitter
ImportError: No module named 'twitter'
Do you get this error in the Terminal ?
If no, try to open the Terminal and run python then import twitter.
Maybe you can try to use pip3 with Python3
First install pip3 then run :
pip3 install twitter
And run again the import in the Terminal.
Recently I faced this issue:
- un-install below packages (twitter, python_twitter).
pip uninstall twitter
pip uninstall python_twitter
Then install Twitter.
pip install twitter
problem will solve.