jantman / python-wifi-survey-heatmap

A Python application for Linux machines to perform WiFi site surveys and present the results as a heatmap overlayed on a floorplan
GNU Affero General Public License v3.0
370 stars 87 forks source link

libnl dependency seemingly not satisfied #7

Closed erik-overdahl closed 2 years ago

erik-overdahl commented 3 years ago

Bug Report

I had to install the latest version (0.3.0) of libnl from PyPi; without it, wifi-survey failed immediately with

$ wifi-survey help
Traceback (most recent call last):
  File "/home/francis/.local/src/python-wifi-survey-heatmap/.venv2/bin/wifi-survey", line 33, in <module>
    sys.exit(load_entry_point('wifi-survey-heatmap', 'console_scripts', 'wifi-survey')())
  File "/home/francis/.local/src/python-wifi-survey-heatmap/.venv2/bin/wifi-survey", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib64/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/ui.py", line 46, in <module>
    from wifi_survey_heatmap.collector import Collector
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/collector.py", line 41, in <module>
    from wifi_survey_heatmap.libnl import Scanner
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/libnl.py", line 55, in <module>
    import libnl.handlers
ModuleNotFoundError: No module named 'libnl'

pip install libnl installs libnl0.2.0, which still does not work - needs to be `pip install libnl3.

Even with libnl3 installed, scancli.py offers up this error

23:40  ~/.local/src/python-wifi-survey-heatmap
$ ./wifi_survey_heatmap/scancli.py 
Traceback (most recent call last):
  File "./wifi_survey_heatmap/scancli.py", line 44, in <module>
    from wifi_survey_heatmap.collector import Collector
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/collector.py", line 41, in <module>
    from wifi_survey_heatmap.libnl import Scanner
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/libnl.py", line 55, in <module>
    import libnl.handlers
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/libnl.py", line 55, in <module>
    import libnl.handlers
ModuleNotFoundError: No module named 'libnl.handlers'; 'libnl' is not a package

scancli.py isn't mentioned in the README, but I was looking for somewhere to get the version info - I don't seem to have 1wifi-survey-heatmapand the other commands do not have a--version` flag.

Version

Most recent commit

Installation Method

git clone https://github.com/jantman/python-wifi-survey-heatmap.git
virtuelenv --system-site-packages --prompt "(wifi-heatmap)" .venv
source ./.venv/bin/activate
python setup.py develop

Supporting Software Versions

$ neofetch
          /:-------------:\          francis@francis-remote 
       :-------------------::        ---------------------- 
     :-----------/shhOHbmp---:\      OS: Fedora release 32 (Thirty Two) x86_64 
   /-----------omMMMNNNMMD  ---:     Host: P2540UA 1.0 
  :-----------sMMMMNMNMP.    ---:    Kernel: 5.10.11-100.fc32.x86_64 
 :-----------:MMMdP-------    ---\   Uptime: 2 days, 10 hours, 14 mins 
,------------:MMMd--------    ---:   Packages: 2814 (rpm) 
:------------:MMMd-------    .---:   Shell: bash 5.0.17 
:----    oNMMMMMMMMMNho     .----:   Resolution: 1920x1080, 1920x1080 
:--     .+shhhMMMmhhy++   .------/   WM: i3 
:-    -------:MMMd--------------:    Theme: Adwaita [GTK2] 
:-   --------/MMMd-------------;     Icons: Adwaita [GTK2] 
:-    ------/hMMMy------------:      Terminal: gnome-terminal 
:-- :dMNdhhdNMMNo------------;       CPU: Intel i5-7200U (4) @ 3.100GHz 
:---:sdNMMMMNds:------------:        GPU: Intel HD Graphics 620 
:------:://:-------------::          Memory: 1879MiB / 31988MiB 
:---------------------://

$ python --version
Python 3.8.7

$ virtualenv --version
virtualenv 20.4.2 from /home/francis/.local/lib/python3.8/site-packages/virtualenv/__init__.py

Actual Output

23:25  ~/.local/src/python-wifi-survey-heatmap
$ wifi-survey --help
Traceback (most recent call last):
  File "/home/francis/.local/src/python-wifi-survey-heatmap/.venv2/bin/wifi-survey", line 33, in <module>
    sys.exit(load_entry_point('wifi-survey-heatmap', 'console_scripts', 'wifi-survey')())
  File "/home/francis/.local/src/python-wifi-survey-heatmap/.venv2/bin/wifi-survey", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib64/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/ui.py", line 46, in <module>
    from wifi_survey_heatmap.collector import Collector
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/collector.py", line 41, in <module>
    from wifi_survey_heatmap.libnl import Scanner
  File "/home/francis/.local/src/python-wifi-survey-heatmap/wifi_survey_heatmap/libnl.py", line 55, in <module>
    import libnl.handlers
ModuleNotFoundError: No module named 'libnl'

Expected Output

$ wifi-survey --help
[2021-02-12 23:31:51,960 WARNING] You should run this script as root to be able to trigger Wi-Fi scans.
usage: wifi-survey [-h] [-v] [-S] [-s IPERF3_SERVER] [-d IPERF3_DURATION] [-b BSSID] [--ding DING] [--ding-command DING_COMMAND] [-i INTERFACE] [-p IMAGE] [-t TITLE]

wifi survey data collection UI

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         verbose output. specify twice for debug-level output.
  -S, --scan            Scan for access points in the vicinity
  -s IPERF3_SERVER, --server IPERF3_SERVER
                        iperf3 server IP or hostname
  -d IPERF3_DURATION, --duration IPERF3_DURATION
                        Duration of each individual ipref3 test run
  -b BSSID, --bssid BSSID
                        Restrict survey to this BSSID
  --ding DING           Path to audio file to play when measurement finishes
  --ding-command DING_COMMAND
                        Path to ding command
  -i INTERFACE, --interface INTERFACE
                        Wireless interface name
  -p IMAGE, --picture IMAGE
                        Path to background image
  -t TITLE, --title TITLE
                        Title for survey (and data filename)

Testing Assistance

Yes

jantman commented 3 years ago

@DL6ER Is there a chance that you have a few minutes to look at this? I believe this is related to the improvements that you contributed in #4.

DL6ER commented 3 years ago

ModuleNotFoundError: No module named 'libnl'

Apparently, the upstream project libnl still hasn't merged my fix for python3.6+ compatibility. More information in this pull request: https://github.com/Robpol86/libnl/pull/29

@erik-overdahl Please try installing my fixed version of libnl using pip3 install --upgrade --user git+https://github.com/DL6ER/libnl

@jantman Sorry, I really assumed they'd merge the fix in. We may have to add this to the README if it works.

erik-overdahl commented 3 years ago

The endpoints defined in setup.py work now but scanclii.py is still broken if called directly

created a new venv "test2", then python setup.py develop before this output:

17:03  ~/.local/src/python-wifi-survey-heatmap
$ pip install --upgrade git+https://github.com/DL6ER/libnl
Collecting git+https://github.com/DL6ER/libnl
  Cloning https://github.com/DL6ER/libnl to /tmp/pip-req-build-ubn2_qf1
  Running command git clone -q https://github.com/DL6ER/libnl /tmp/pip-req-build-ubn2_qf1
Building wheels for collected packages: libnl
  Building wheel for libnl (setup.py) ... done
  Created wheel for libnl: filename=libnl-0.2.0-py3-none-any.whl size=89468 sha256=bfa9205d88af2e54f521146c35ebe192298f4fd9eadac0677c20c43380b1ffab
  Stored in directory: /tmp/pip-ephem-wheel-cache-3tedhnnp/wheels/e7/df/e7/13096e185ec166c869f7718a7c545c43851fcc0c99781fb9e8
Successfully built libnl
Installing collected packages: libnl
Successfully installed libnl-0.2.0

test2
17:05  ~/.local/src/python-wifi-survey-heatmap
$ wifi-survey --help
[2021-02-14 17:05:12,800 WARNING] You should run this script as root to be able to trigger Wi-Fi scans.
usage: wifi-survey [-h] [-v] [-S] [-s IPERF3_SERVER] [-d IPERF3_DURATION] [-b BSSID] [--ding DING] [--ding-command DING_COMMAND] [-i INTERFACE] [-p IMAGE] [-t TITLE]

wifi survey data collection UI

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         verbose output. specify twice for debug-level output.
  -S, --scan            Scan for access points in the vicinity
  -s IPERF3_SERVER, --server IPERF3_SERVER
                        iperf3 server IP or hostname
  -d IPERF3_DURATION, --duration IPERF3_DURATION
                        Duration of each individual ipref3 test run
  -b BSSID, --bssid BSSID
                        Restrict survey to this BSSID
  --ding DING           Path to audio file to play when measurement finishes
  --ding-command DING_COMMAND
                        Path to ding command
  -i INTERFACE, --interface INTERFACE
                        Wireless interface name
  -p IMAGE, --picture IMAGE
                        Path to background image
  -t TITLE, --title TITLE
                        Title for survey (and data filename)

test2
17:05  ~/.local/src/python-wifi-survey-heatmap
$ ./wifi_survey_heatmap/scancli.py 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
scancli.py 44 <module>
from wifi_survey_heatmap.collector import Collector

collector.py 41 <module>
from wifi_survey_heatmap.libnl import Scanner

libnl.py 55 <module>
import libnl.handlers

libnl.py 55 <module>
import libnl.handlers

ModuleNotFoundError:
No module named 'libnl.handlers'; 'libnl' is not a package
jantman commented 2 years ago

This should be fixed with 1.0.0 which was just released. Please feel free to re-open if it hasn't been.