install-ubuntu-python3.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. # This script must be run as root
  8. if [[ $EUID -ne 0 ]]
  9. then
  10. echo "This script must be run as root (sudo)"
  11. exit 1
  12. fi
  13. # Install python3 if necessary
  14. python3 --version >/dev/null 2>&1
  15. if [ $? -ne 0 ]
  16. then
  17. echo Installing Python3
  18. apt-get install python3
  19. if [ $? -ne 0 ]
  20. then
  21. echo Error installing python3
  22. exit 1
  23. fi
  24. else
  25. PYTHON_VERSION=$(python3 --version)
  26. echo Python3 already installed \($PYTHON_VERSION\)
  27. fi
  28. # Install python3 pip if necessary
  29. pip3 --version >/dev/null 2>&1
  30. if [ $? -ne 0 ]
  31. then
  32. echo Installing Python3 PIP
  33. apt-get install -y python3-pip
  34. if [ $? -ne 0 ]
  35. then
  36. echo Error installing python3
  37. exit 1
  38. fi
  39. else
  40. PYTHON_VERSION=$(pip3 --version | awk '{print $2}')
  41. echo Python3 Pip already installed \($PYTHON_VERSION\)
  42. fi
  43. # Read from the package list and process each package
  44. PIP_REQUIREMENTS_FILE=requirements.txt
  45. pip3 install -r $PIP_REQUIREMENTS_FILE
  46. if [ $? -ne 0 ]
  47. then
  48. echo Error installing python3
  49. exit 1
  50. fi
  51. echo Python3 setup complete
  52. exit 0