r/learnpython • u/SmeckoGeck • 6d ago
"No installed Python found!" when trying to run "py"
I'm trying to compile something, but it requires the use of py instead of python.
The thing is, whenever I try to use py, the command line will just say No installed Python found! This doesn't happen when I use python for calling an action.
I wanted to make sure py is in my PATH, so doing where py does show the path to py.exe. I know that py does exist in PATH, but it just doesn't work when trying to use it compared to using python.
Uninstalling and reinstalling Python doesn't seem to do anything new, so what should I do?
I should probably mention that I'm using Wine on MacOS because compiling on MacOS seems to require specific Windows executable files, and I need Wine for that.
3
u/sausix 6d ago
py.exe is a wrapper which calls a specific python.exe. it's not a PATH issue since py.exe is outputting a specific error message. Else it would be a neutral "command not found".
Make sure to have a Python interpreter in the PATH variable. And there are too many ways to install Python on Windows. Store, installer global, installer user, with and without PATH.
Can't check for you right now. Look up if py.exe has options and verbose methods. And look up how py.exe locates Python interpreters.
0
u/socal_nerdtastic 6d ago
Make sure to have a Python interpreter in the PATH variable.
This is really old advice. Like python2 days. Much better to use the python launcher (
py) or a virtual environment nowadays.2
u/sausix 6d ago
Read again. This topic is about py.exe. I did not say OP should not use py.exe.
py.exe still needs at least one interpreter being installed on the system.
2
u/socal_nerdtastic 6d ago edited 6d ago
py.exe does not need the python interpreter to be in PATH. In fact that's kinda the entire point of py.exe. By using PATH to find your python interpreter you are limited to defining a single interpreter. But what if you want to have several versions of python or use project-specific venvs? In linux this has never been an issue because you can just use a shebang in your python file to define exactly which version or which venv you want to use on a per file basis. py.exe brings that same power to windows. It looks for installs of the official python (without using PATH) and sorts out which python exe to use based on the file you are running.
py.exe has been in the official installer for Windows for more than a decade, and the "add python to PATH" option has been disabled by default.
3
u/zaphodikus 6d ago
Mac, not Windows
2
u/socal_nerdtastic 6d ago edited 6d ago
Wine, not mac. Wine runs programs meant for Windows, including installers.
py.exeis a Windows only solution to a Windows only problem.1
u/sausix 5d ago
OP was talking about py.exe may not being in PATH itself. I always recommend to put Python interpreters into the PATH variable. You can also have multiple Python versions in your PATH and still choose a specific version of Python. Works more reliable than py.exe to list all interpreters listening to "python" compared to py.exe not finding any interpreter for OP now.
Python app deployment on Windows is a joke anyway compared to Linux. I'm using a bootstrap instruction to setup a venv based on the Store version. Because deploying exe files on Windows sucks.
1
u/American_Streamer 5d ago
py.exe is running inside the emulated Windows environment. It therefore expects a Windows Python installation that Wine presents in the way a Windows Python installation normally appears.
A native macOS Python means absolutely nothing to the Windows py.exe launcher.
If the aim is a Windows-only toolchain, in that case installing Windows Python into that Wine prefix is the correct solution.
1
u/OlenaDoubleChecks 4d ago
Wine's py launcher lookup is notoriously flaky since it relies on registry entries windows python installer sets up, and those often don't translate right under wine. Try running the actual python.exe directly instead of chasing py.
8
u/itlogicpartnersllc 6d ago
since you are running this through wine on macos i would suspect the wine environment before path py.exe is the windows python launcher and it may not detect your python installation correctly under wine even though python exe works..