From 809cbfc9693d693697389a180f901745c4de0d47 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 19 Sep 2024 11:15:22 +0200 Subject: [PATCH] Update plugin.py --- a00_qpip/plugin.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/a00_qpip/plugin.py b/a00_qpip/plugin.py index 3b735b9..ba718ff 100644 --- a/a00_qpip/plugin.py +++ b/a00_qpip/plugin.py @@ -234,7 +234,7 @@ def pip_uninstall_reqs(self, reqs_to_uninstall, extra_args=[]): run_cmd( [ - sys.executable, + self.python_command(), "-um", "pip", "uninstall", @@ -251,13 +251,9 @@ def pip_install_reqs(self, reqs_to_install): os.makedirs(self.prefix_path, exist_ok=True) log(f"Will pip install {reqs_to_install}") - # python is normally found at sys.executable, but there is a bug on windows qgis so use 'python' instead - # https://github.com/qgis/QGIS/issues/45646 - python_command = 'python' if os.name == 'nt' else sys.executable - run_cmd( [ - python_command, + self.python_command(), "-um", "pip", "install", @@ -268,6 +264,11 @@ def pip_install_reqs(self, reqs_to_install): f"installing {len(reqs_to_install)} requirements", ) + def python_command(self): + # python is normally found at sys.executable, but there is an issue on windows qgis so use 'python' instead + # https://github.com/qgis/QGIS/issues/45646 + return "python" if os.name == "nt" else sys.executable + def check(self): dialog, _ = self.check_deps() self.promt_install(dialog)