From 426efb515fd909657c6d3b786792513eefec7f7f Mon Sep 17 00:00:00 2001 From: David Lechner Date: Wed, 13 Oct 2021 14:22:49 -0500 Subject: [PATCH] setup: fix installing in virtual env on Ubuntu This fixes running the Ubuntu setup script in a Python virtual environment. This was failing because pip doesn't allow the --user option in virtual environments. --- Tools/setup/ubuntu.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Tools/setup/ubuntu.sh b/Tools/setup/ubuntu.sh index 9761fcf40c..88d27581de 100755 --- a/Tools/setup/ubuntu.sh +++ b/Tools/setup/ubuntu.sh @@ -108,7 +108,13 @@ fi # Python3 dependencies echo echo "Installing PX4 Python3 dependencies" -python3 -m pip install --user -r ${DIR}/requirements.txt +if [ -n "$VIRTUAL_ENV" ]; then + # virtual envrionments don't allow --user option + python -m pip install -r ${DIR}/requirements.txt +else + # older versions of Ubuntu require --user option + python3 -m pip install --user -r ${DIR}/requirements.txt +fi # NuttX toolchain (arm-none-eabi-gcc) if [[ $INSTALL_NUTTX == "true" ]]; then