0

If I launch python --version from Terminal on macOS, I'm getting 3.9 version. The same is for python3.

But if I launch these from my C++ program (I use QProcess), I'm getting 2.7 for python and 3.7 for python3.

Why so?

Is there any way to launch the same python version as terminal launches?

Is there a way to find path to the latest python installed on the machine (I need to support macOS and Linux).

Addition #1. On another macOS machine, there is Python 3.10 installed in /Applications folder. python3 --version shows expected 3.10 version, but my C++ program does not even see this python3, so macOS displays its system error message which suggests the user to install additional components (which does not work through). enter image description here

Alexander Dyagilev
  • 1,139
  • 1
  • 15
  • 43

1 Answers1

0

This is an issue with macOS. An app launched from the Dock has a different PATH environment variable than the shell has. Here is a question about how to fix this: Get bash $PATH from C++ program

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Alexander Dyagilev
  • 1,139
  • 1
  • 15
  • 43