From 984caedfac740ab5ab519a8c7541475460b5fcef Mon Sep 17 00:00:00 2001 From: Senko Rasic Date: Wed, 5 Jun 2024 08:44:49 +0200 Subject: [PATCH] fix error message in case of missing Python packages --- main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index e22dcfd9e..db271215e 100644 --- a/main.py +++ b/main.py @@ -6,20 +6,23 @@ try: from core.cli.main import run_pythagora -except ImportError: - pythagora_root = os.path.dirname(os.path.dirname(__file__)) +except ImportError as err: + pythagora_root = os.path.dirname(__file__) venv_path = os.path.join(pythagora_root, "venv") requirements_path = os.path.join(pythagora_root, "requirements.txt") if sys.prefix == sys.base_prefix: venv_python_path = os.path.join(venv_path, "scripts" if sys.platform == "win32" else "bin", "python") - print("Python environment for Pythagora is not set up.", file=sys.stderr) + print(f"Python environment for Pythagora is not set up: module `{err.name}` is missing.", file=sys.stderr) print(f"Please create Python virtual environment: {sys.executable} -m venv {venv_path}", file=sys.stderr) print( f"Then install the required dependencies with: {venv_python_path} -m pip install -r {requirements_path}", file=sys.stderr, ) else: - print("Python environment for Pythagora is not completely set up.", file=sys.stderr) + print( + f"Python environment for Pythagora is not completely set up: module `{err.name}` is missing", + file=sys.stderr, + ) print( f"Please run `{sys.executable} -m pip install -r {requirements_path}` to finish Python setup, and rerun Pythagora.", file=sys.stderr,