Python Forum
Help: ImportError: No module named 'pygatt'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help: ImportError: No module named 'pygatt'
#1
Hi
I am trying to do the first steps on python. I am using Linux Ubuntu and I am trying to capture BLE advertisements data.

I did:
pip install pygatt
sudo apt install python-pip
pip install "pygatt[GATTTOOL]"
pip install git+https://github.com/peplin/pygatt

$ python3 -V
Python 3.5.2

Then: test.py

import pygatt
adapter = pygatt.Adapter()
for device in adapter.discover():
print (device.mac)


When executing it:

$python3 test.py

I get:

Traceback (most recent call last):
File "test.py", line 1, in <module>
import pygatt
ImportError: No module named 'pygatt'


Thanks a lot
imo
Reply
#2
Default on Ubuntu so is pip installing to Python 2.
You most use pip3.
# Install pip3
sudo apt install python3-pip

# Test 
pip3 -V

# Use pip3 
pip3 install pygatt
Look at Linux Python 3 environment
Reply
#3
Great it worked. but now:

adapter = pygatt.Adapter()
AttributeError: module 'pygatt' has no attribute 'Adapter'
Reply
#4
That's because there is no Adapter() method in pygatt.
If you look at usage:
import pygatt

adapter = pygatt.GATTToolBackend()

# Then adapter has is own method like eg start,connect,stop ...ect.
>>> help(adapter.start)
Help on method start in module pygatt.backends.bgapi.bgapi:

start() method of pygatt.backends.bgapi.bgapi.BGAPIBackend instance
    Connect to the USB adapter, reset it's state and start a backgroud
    receiver thread.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 850 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 23,616 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,510 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,417 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,483 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,311 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 1,020 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 8,891 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 994 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 1,820 Oct-20-2022, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020