2016-07-03 41 views
0

Ich habe ein Problem mit Pubhub-Modul in Python 2.7.6.ImportError: Name kann nicht importiert werden pubnub

Ich habe installiert von sudo pip install pubnub

Ausgang:

>>> import pubnub 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "pubnub.py", line 3, in <module> 
    from pubnub import Pubnub 
ImportError: cannot import name Pubnub 

>>> from pubnub import Pubnub 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "pubnub.py", line 3, in <module> 
    from pubnub import Pubnub 
ImportError: cannot import name Pubnub 

ich neu installiert Anfragen, python-dev und pubnub. Nichts

half

In Hilfe (‚Module‘) gibt Modul ist pubnub

+0

Haben Sie mehr als eine Python-Installation, haben Sie Anaconda installiert? –

+0

Nur 2.7.6. Anaconda ist nicht installiert –

+0

Ich empfehle, alle pubnub Daten zu entfernen und eine "pip install pubnub" wieder – AK1

Antwort

1

Sie haben eine Datei in Ihrem Projekt mit dem Namen pubnub.py, die der Importeur vor der Installation des pubnub Modul zu finden, denke ich. Benennen Sie Ihre Datei in etwas anderes um, und alles sollte funktionieren.

1

Ich umbenannte Datei, python3 entfernt (es wurde noch installiert: D), und entfernt alle * .pyc-Dateien und es funktioniert für jetzt. Dank

1

für Version 4 von pubnub die Instanziierung geändert hat,

from pubnub import pubnub 
pnconf = pubnub.PNConfiguration() 
pnconf.subscribe_key = 'demo' 
pnconf.publish_key = 'demo' 

pubnub = pubnub.PubNub(pnconf) 

für weitere Informationen lesen ihre Dokumentation v4 upgrading for pubnub

0

ich das gleiche Problem auf meinem Raspberry Pi 3. Es erlebte eine sehr endete als dumme Frage! Ich hatte eine Datei namens pubnub.py, weshalb, wenn ich mein Skript ausgeführt habe, als es im Ordner "Desktop" gefunden wurde, hat es nicht funktioniert. Nachdem ich es jedoch in sein Elternverzeichnis "pi" gebracht hatte, importierte es pubnub ohne ein Problem!

Verwandte Themen