From ebcc4936f7bfbdc9b026d52880f2935d19c932f0 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 20 Oct 2023 11:06:44 -0700 Subject: [PATCH] Update pitft to run in venv --- adafruit-pitft.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adafruit-pitft.py b/adafruit-pitft.py index d8f8493..100f32c 100755 --- a/adafruit-pitft.py +++ b/adafruit-pitft.py @@ -7,14 +7,15 @@ Written in Python by Melissa LeBlanc-Williams for Adafruit Industries import time import os +import sys try: import click except ImportError: - raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install Click") + raise RuntimeError("The library 'Click' was not found. To install, try typing: pip3 install Click") try: from adafruit_shell import Shell except ImportError: - raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") + raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: pip3 install adafruit-python-shell") shell = Shell() shell.group = 'PITFT' @@ -242,7 +243,8 @@ def softwareinstall(): warn_exit("Apt failed to install TSLIB!") if not shell.run_command("apt-get install -y bc fbi git python3-dev python3-pip python3-smbus python3-spidev evtest libts-bin device-tree-compiler libraspberrypi-dev build-essential"): warn_exit("Apt failed to install software!") - if not shell.run_command("pip3 install evdev"): + pip_path = f"{os.path.dirname(sys.executable)}/pip3" + if not shell.run_command(f"{pip_path} install evdev", run_as_user=os.environ["SUDO_USER"]): warn_exit("Pip failed to install software!") return True