Skip to content
This repository was archived by the owner on Oct 26, 2023. It is now read-only.
This repository was archived by the owner on Oct 26, 2023. It is now read-only.

README venv installation instructions are incorrect #274

@harristom

Description

@harristom

On a clean system, following the README instructions for venv installation exactly as written doesn't work.

$ source .venv/bin/activate
$ sudo ./gateway.py
Traceback (most recent call last):
  File "/home/pi/bt-mqtt-gateway/./gateway.py", line 11, in <module>
    import logger
  File "/home/pi/bt-mqtt-gateway/logger.py", line 3, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

I admit I'm not super familiar with python but afaik it doesn't make sense to activate the venv and then run sudo, as the env vars (specifically the python path) set by activating will anyway be ignored once we are running as a root so we will effectively be running outside the venv and thus will be missing the dependencies that were installed inside it.

./gateway.py would run using the venv packages but on my system at least it fails because you need to be root to run the BT scan. Calling the venv's python binary directly as root seems to work (no need to activate venv first but equally wouldn't do any harm):
$ sudo .venv/bin/python gateway.py

Similarly, service.sh needs to be edited. It correctly sets the PATH to include the venv path but then undoes that work by using sudo, which is unnecessary as systemd services already run as root afaik. Simply removing sudo from the last line fixes it, i.e.:
python3 ./gateway.py "$@"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions