How to import PubNub

198 Views Asked by At

Hello I import Pubnub in my python file I already installed Pubnub in python env, it's installed just fine but when I try to be import,it's not imported in my python file, Can anybody help me below I also attach some screenshotsenter image description here

1

There are 1 best solutions below

0
Sergio M On

As stated in the PubNub Python Docs:

Install pubnub using pip:

pip install 'pubnub>=7.0.0'

In your python main add:

from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub

pnconfig = PNConfiguration()

pnconfig.subscribe_key = 'mySubscribeKey'
pnconfig.publish_key = 'myPublishKey'
pnconfig.user_id = "my_custom_user_id"
pubnub = PubNub(pnconfig)

Remember to always set your user_id in the pnconfig object.

Finally, add the callback listeners like in this full sample: PubNub Python Putting it together