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

README venv installation instructions are incorrect #274

Open
harristom opened this issue Oct 8, 2023 · 0 comments
Open

README venv installation instructions are incorrect #274

harristom opened this issue Oct 8, 2023 · 0 comments

Comments

@harristom
Copy link

harristom commented Oct 8, 2023

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 "$@"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant