This might be a possible duplicate, but i wasn't able to find a solution in the link here. I am new to raspberry PI I wish to use Pubnub to communicate with an android application and a Raspberry Pi. I have a raspberry Pi 3 model B with a freshly installed Raspbian OS.
I followed the initial steps from here.
Install Python:
pi@raspberrypi ~$ sudo apt-get install python-dev
Install pip:
pi@raspberrypi ~$ sudo apt-get install python-pip
install PubNub:
pi@raspberrypi ~$ sudo pip install pubnub
then I wrote the exact code and saved it as hello.py with my publish and subscription keys:
import sys
from pubnub import Pubnub
pubnub = Pubnub(publish_key='<your-pub-key>', subscribe_key='<your-sub-key>')
channel = 'hello-pi'
data = {
'username': 'Your name',
'message': 'Hello World from Pi!'
}
def callback(m):
print(m)
pubnub.publish(channel, data, callback=callback, error=callback)
and i am getting this error:
Traceback (most recent call last):
File "hello.py", line 2, in <module>
from pubnub import Pubnub
ImportError: cannot import name Pubnub
Cannot find a solution and it is a very annoying error this early in my project. Please help.
thanks in advance.