2015-07-19 28 views
1

我對Python很新,我試圖讓Pybluez爲我工作。PyBluez的模塊對象沒有任何屬性'discover_devices'

這是當我嘗試發現藍牙設備時會發生什麼。

import bluetooth 
nearby_devices = bluetooth.discover_devices() 

Traceback (most recent call last): 
    File "<stdin>",line1,in <module> 
AttributeError: 'module' object has no attribute 'discover_devices' 

我在Windows 8.1中,蟒蛇2.7.10,pybluez 0.21

回答

4

我有同樣的問題,我做我的命名程序文件bluetooth.py,這混淆蟒蛇爲包解決的錯誤,如果情況確實如此,你應該注意這個愚蠢的錯誤。

如果不是這種情況,那麼嘗試把你的文件放在你的藍牙目錄(在我的情況下,C:\Python27\Lib\site-packages)所在的目錄中,然後從那裏運行它,它對我很有用。

+0

太傻了,謝謝。我也將我的文件命名爲bluetooth.py。 –

相關問題