-
Notifications
You must be signed in to change notification settings - Fork 222
Description
to avoid #236 and because the current default python "py" is not present if there is only a per-user python installed.
Initially I thought of just switching back to "python" but unfortunately there is a problem with using "python" by default - it turns out that when the windows python alias is launched with a argument it exits with error code 9009 (file not found) instead of bringing the Microsoft store up to install python. So you could end up in a situation where python is installed but not in the PATH, causing confusion to users who think python-shell should work properly with python installed. I guess I could require the user to manually specify the path, but then what is the point of python-shell is it doesn't handle complexities for you? Ideally I would handle it automatically. To do so I'm thinking of the following:
if unix: launch python
else:
if string "python" is in PATH: # or maybe just search for "ython" so jython implementation works
launch "python"
else if "C:\\Windows\\py" file exists:
launch py
else:
raise PYTHON_NOT_FOUND error
# PYTHON_NOT_FOUND -> "python is either not installed, installed in a non-standard location, or not in the PATH"
I would also provide a "install()" method that would install python from the windows store. It would be the users responsibility to run the method if desired when a PYTHON_NOT_FOUND appears.
I suppose I could go even further and if python is not in PATH or py not existing, I could check C:\Users\caleb\AppData\Local\Programs\Python
, parse the version numbers, get the latest version, and execute C:\Users\caleb\AppData\Local\Programs\Python\Python<<version>>\python.exe
... bleh. I think I would save that for later.
I did some research on how other code systems launch python:
node-python-bridge: simply launches "python"
https://github.com/microsoft/vscode-python/tree/main/src/client/pythonEnvironments: oh god it's so complex. I looked a bit through here but I would need to do a thorough investigation to understand what's going on.